Table load complete. Printer stub removed for actual code.

This commit is contained in:
unknown 2011-01-14 01:51:02 +05:30
parent c63bc62304
commit 76cd512ebc
16 changed files with 230 additions and 29 deletions

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.DAOFactory;
using System.Data.SqlClient;
using Tanshu.Data.DAO;
namespace Tanshu.Accounts.BI
{
public class PrintLocationBI : IPrintLocationBI
{
public void Insert(PrintLocationBO printLocation)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IPrintLocationDAO dao = factory.GetPrintLocationDAO(connection))
{
dao.Insert(printLocation);
}
}
}
public void Update(PrintLocationBO printLocation)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IPrintLocationDAO dao = factory.GetPrintLocationDAO(connection))
{
dao.Update(printLocation);
}
}
}
public bool Delete(int tableID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IPrintLocationDAO dao = factory.GetPrintLocationDAO(connection))
{
return dao.Delete(tableID);
}
}
}
public PrintLocationBO GetPrintLocation(int printLocationID)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IPrintLocationDAO dao = factory.GetPrintLocationDAO(connection))
{
return dao.GetPrintLocation(printLocationID);
}
}
}
public PrintLocationBO GetPrintLocation(Guid productTypeID, string location)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (IPrintLocationDAO dao = factory.GetPrintLocationDAO(connection))
{
return dao.GetPrintLocation(productTypeID, location);
}
}
}
}
}

View File

@ -64,6 +64,7 @@
<ItemGroup>
<Compile Include="AdvanceBI.cs" />
<Compile Include="CheckoutBI.cs" />
<Compile Include="PrintLocationBI.cs" />
<Compile Include="FoodTableBI.cs" />
<Compile Include="ProductTypeBI.cs" />
<Compile Include="CustomerBI.cs" />

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.DAOFactory
{
public interface IPrintLocationDAO : IDisposable
{
void Insert(PrintLocationBO printLocation);
void Update(PrintLocationBO printLocation);
bool Delete(int tableID);
PrintLocationBO GetPrintLocation(int printLocationID);
PrintLocationBO GetPrintLocation(Guid productTypeID, string location);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
public class PrintLocationBO
{
public int PrintLocationID { get; set; }
public Guid ProductTypeID { get; set; }
public string Location { get; set; }
public string Printer { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
public interface IPrintLocationBI
{
void Insert(PrintLocationBO printLocation);
void Update(PrintLocationBO printLocation);
bool Delete(int tableID);
PrintLocationBO GetPrintLocation(int printLocationID);
PrintLocationBO GetPrintLocation(Guid productTypeID, string location);
}
}

View File

@ -56,6 +56,7 @@
<Compile Include="Communication\Delegates.cs" />
<Compile Include="DAOFactory\CheckoutDAO.cs" />
<Compile Include="DAOFactory\AdvanceDAO.cs" />
<Compile Include="DAOFactory\PrintLocationDAO.cs" />
<Compile Include="DAOFactory\FoodTableDAO.cs" />
<Compile Include="DAOFactory\ProductTypeDAO.cs" />
<Compile Include="DAOFactory\ManagementDAO.cs" />
@ -76,6 +77,7 @@
<Compile Include="Data Contracts\AdvanceDisplayBO.cs" />
<Compile Include="Data Contracts\ComplexProductBO.cs" />
<Compile Include="Data Contracts\BillItemKey.cs" />
<Compile Include="Data Contracts\PrintLocationBO.cs" />
<Compile Include="Data Contracts\FoodTableBO.cs" />
<Compile Include="Data Contracts\SalarySheetBO.cs" />
<Compile Include="Data Contracts\SalarySheetDisplayBO.cs" />
@ -112,6 +114,7 @@
<Compile Include="Roles.cs" />
<Compile Include="Service Contracts\AdvanceBI.cs" />
<Compile Include="Service Contracts\CheckoutBI.cs" />
<Compile Include="Service Contracts\PrintLocationBI.cs" />
<Compile Include="Service Contracts\FoodTableBI.cs" />
<Compile Include="Service Contracts\ProductTypesBI.cs" />
<Compile Include="Service Contracts\CustomerBI.cs" />

View File

@ -25,6 +25,7 @@ namespace Tanshu.Accounts.DAOFactory
public abstract IManagementDAO GetManagementDAO(DateTime startDate, DateTime finishDate, IConnectionDAO connection);
public abstract IMembershipDAO GetMembershipDAO(IConnectionDAO connection);
public abstract IPaymentDAO GetPaymentDAO(IConnectionDAO connection);
public abstract IPrintLocationDAO GetPrintLocationDAO(IConnectionDAO connection);
public abstract IProductDAO GetProductDAO(IConnectionDAO connection);
public abstract IProductTypeDAO GetProductTypeDAO(IConnectionDAO connection);
public abstract ISalesAnalysisDAO GetSalesAnalysisDAO(IConnectionDAO connection);

View File

@ -59,6 +59,11 @@ namespace Tanshu.Accounts.DAOFactory
return new PaymentDAO(connection);
}
public override IPrintLocationDAO GetPrintLocationDAO(IConnectionDAO connection)
{
return new PrintLocationDAO(connection);
}
public override IProductDAO GetProductDAO(IConnectionDAO connection)
{
return new ProductDAO(connection);

View File

@ -99,7 +99,7 @@ namespace Tanshu.Accounts.Helpers
}
}
}
public static void GenerateButtons(ref Panel panel, ref List<Button> buttonList, Rectangle clientArea, int x, int y, int border, List<FoodTableBO> list, ButtonClickDelegate bcDelegate)
public static void GenerateTables(ref Panel panel, ref List<Button> buttonList, Rectangle clientArea, int x, int y, int border, List<FoodTableBO> list, ButtonClickDelegate bcDelegate)
{
if (buttonList.Count != 0)
{
@ -121,7 +121,6 @@ namespace Tanshu.Accounts.Helpers
if (list.Count < count)
break;
left = clientArea.Left + (i * (width + border));
//ProductTypeBO item = list[(j * x) + i];
FoodTableBO item = list[count - 1];
Button btn = GetButton(string.Format("{0}-{1}", i, j), item.Name, width, height, left, top, item.TableID, bcDelegate);
panel.Controls.Add(btn);

View File

@ -4,6 +4,7 @@
<add name="connection" connectionString="Server=.;Initial Catalog=PeithoSales;User ID=sa;Password=123456" />
</connectionStrings>
<appSettings>
<add key ="Location" value ="Ground"/>
<add key ="Factory" value ="SqlServer"/>
<add key ="LogConnection" value ="connection"/>
<add key ="LogLevel" value ="Warn"/>

View File

@ -30,9 +30,5 @@ namespace Tanshu.Accounts.PointOfSale
}
}
}
static public string printer()
{
return "";
}
}
}

View File

@ -394,22 +394,34 @@ namespace Tanshu.Accounts.PointOfSale
ShowAmount();
}
public void LoadBillFromTable()
public void LoadBillFromTable(string tableName)
{
InputBoxResult result = InputBox.Show("Enter Table Number", "Table", "0", InputBox_Validating);
if (result.OK)
if (!string.IsNullOrEmpty(tableName))
{
string tableID = result.Text.Trim();
if ((tableID != "C") && (tableID != "") && (!tableID.Contains(".")))
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(tableName);
if (tID.HasValue)
{
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(tableID);
if (tID.HasValue)
{
LoadBill(tID.Value);
}
LoadBill(tID.Value);
}
}
else
{
InputBoxResult result = InputBox.Show("Enter Table Number", "Table", "0", InputBox_Validating);
if (result.OK)
{
string tableID = result.Text.Trim();
if ((tableID != "C") && (tableID != "") && (!tableID.Contains(".")))
{
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(tableID);
if (tID.HasValue)
{
LoadBill(tID.Value);
}
}
else
ClearBill();
}
else
ClearBill();
}
}

View File

@ -20,7 +20,7 @@ namespace Tanshu.Accounts.PointOfSale
List<Button> buttonHeads = new List<Button>();
int page = 0;
int pageSize = 6;
public SalesForm(BillController billController)
{
InitializeComponent();
@ -76,7 +76,7 @@ namespace Tanshu.Accounts.PointOfSale
}
case Keys.F8:
{
billController.LoadBillFromTable();
billController.LoadBillFromTable(null);
break;
}
case Keys.F9:
@ -149,8 +149,31 @@ namespace Tanshu.Accounts.PointOfSale
txtGrossAmount.Text = "0.00";
txtAmount.Text = "0.00";
bindingSource.DataSource = bill.Values;
ChangeFormState(SaleFormState.Waiting);
}
private void ChangeFormState(SaleFormState state)
{
foreach (var button in buttonList)
button.Dispose();
foreach (var button in buttonHeads)
button.Dispose();
buttonList = new List<Button>();
buttonHeads = new List<Button>();
if (state == SaleFormState.Billing)
{
btnPrevious.Visible = true;
btnNext.Visible = true;
page = 0;
var list = new ProductTypeBI().GetProductTypes();
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 90, 85, 498), 1, pageSize, 2, page, list, new ButtonClickDelegate(productTypeButton_Click));
}
else
{
btnPrevious.Visible = false;
btnNext.Visible = false;
ControlFactory.GenerateTables(ref pnlBilling, ref buttonHeads, new Rectangle(390, 94, 499, 385), 6, 10, 2, new FoodTableBI().GetFoodTables(), new ButtonClickDelegate(tableButton_Click));
}
}
private void productTypeButton_Click(object sender, EventArgs e)
{
Button button = sender as Button;
@ -172,9 +195,10 @@ namespace Tanshu.Accounts.PointOfSale
Button button = sender as Button;
if (button == null)
return;
int tag = (int)button.Tag;
MessageBox.Show("Table No " + tag.ToString());
//AddProductToGrid(tag);
string tableName = button.Text;
billController.LoadBillFromTable(tableName);
txtTableID.Text = tableName;
ChangeFormState(SaleFormState.Billing);
}
public void ShowAmount(decimal grossTax, decimal discount, decimal grossAmount, decimal amount, List<SalesBillItemBO> bill)
{
@ -225,10 +249,7 @@ namespace Tanshu.Accounts.PointOfSale
private void SalesForm_Load(object sender, EventArgs e)
{
billController.FormLoad();
//ControlFactory.GenerateButtons(ref pnlBilling, new Rectangle(489, 94, 400, 385), 5, 6, 2, new ProductBI().GetUnFilteredProducts(), new ButtonClickDelegate(productButton_Click));
//ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 0, 80, 688), 1, pageSize, 2, page, new ProductTypeBI().GetProductTypes(), new ButtonClickDelegate(productTypeButton_Click));
//ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(889, 90, 85, 498), 1, pageSize, 2, page, new ProductTypeBI().GetProductTypes(), new ButtonClickDelegate(productTypeButton_Click));
ControlFactory.GenerateButtons(ref pnlBilling, ref buttonHeads, new Rectangle(390, 94, 499, 385), 6, 10, 2, new FoodTableBI().GetFoodTables(), new ButtonClickDelegate(tableButton_Click));
ChangeFormState(SaleFormState.Waiting);
}
private void btnCustomer_Click(object sender, EventArgs e)

View File

@ -49,9 +49,10 @@ namespace Tanshu.Accounts.SqlDAO
return (int)connection.ExecuteScalar(cmd) >= 0 ? true : false;
}
//Upgraded to use Groups
public bool IsUserInRole(Guid userID, string roleName)
{
SqlCommand cmd = new SqlCommand("SELECT Count(*) FROM UserRoles ur WHERE ur.UserID = @UserID AND ur.Role = @Role");
SqlCommand cmd = new SqlCommand("SELECT Count(*) FROM UserGroups ug INNER JOIN RoleGroups rg on ug.GroupID = rg.GroupID WHERE ug.UserID = @UserID AND rg.RoleID = @Role");
cmd.Parameters.AddWithValue("@UserID", userID);
cmd.Parameters.AddWithValue("@Role", roleName);

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using Tanshu.Accounts.Contracts;
using Tanshu.Data.DAO;
using Tanshu.Accounts.DAOFactory;
namespace Tanshu.Accounts.SqlDAO
{
public class PrintLocationDAO : BaseDAO, IPrintLocationDAO
{
public PrintLocationDAO(IConnectionDAO connection)
: base(connection)
{ }
public void Insert(PrintLocationBO printLocation)
{
throw new NotImplementedException();
}
public void Update(PrintLocationBO printLocation)
{
throw new NotImplementedException();
}
public bool Delete(int tableID)
{
throw new NotImplementedException();
}
public PrintLocationBO GetPrintLocation(int printLocationID)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM PrintLocations WHERE PrintLocationID = @PrintLocationID;");
cmd.Parameters.AddWithValue("@PrintLocationID", printLocationID);
return BusinessObjectDAO<PrintLocationBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public PrintLocationBO GetPrintLocation(Guid productTypeID, string location)
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM PrintLocations WHERE ProductTypeID = @ProductTypeID AND Location = @Location"))
{
cmd.Parameters.AddWithValue("@ProductTypeID", productTypeID);
cmd.Parameters.AddWithValue("@Location", location);
return BusinessObjectDAO<PrintLocationBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
}
}
}

View File

@ -61,6 +61,7 @@
<Compile Include="AdvanceDAO.cs" />
<Compile Include="BaseDAO.cs" />
<Compile Include="CheckoutDAO.cs" />
<Compile Include="PrintLocationDAO.cs" />
<Compile Include="FoodTableDAO.cs" />
<Compile Include="ProductTypeDAO.cs" />
<Compile Include="SqlConnectionDAO.cs" />