diff --git a/Include/System.Data.SQLite.dll b/Include/System.Data.SQLite.dll deleted file mode 100644 index 080c74c..0000000 Binary files a/Include/System.Data.SQLite.dll and /dev/null differ diff --git a/Include/Tanshu.Logging.dll b/Include/Tanshu.Logging.dll deleted file mode 100644 index a1e6b01..0000000 Binary files a/Include/Tanshu.Logging.dll and /dev/null differ diff --git a/Resources/Hops n Grains_1048.jpg b/Resources/Hops n Grains_1048.jpg new file mode 100644 index 0000000..60e697f Binary files /dev/null and b/Resources/Hops n Grains_1048.jpg differ diff --git a/Resources/burger.ico b/Resources/burger.ico new file mode 100644 index 0000000..2ed507b Binary files /dev/null and b/Resources/burger.ico differ diff --git a/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs b/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs new file mode 100644 index 0000000..4276778 --- /dev/null +++ b/Tanshu.Accounts.Contracts/Attributes/InverseAttribute.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Tanshu.Accounts.Contracts +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class InverseAttribute : Attribute + { + private string message = string.Empty; + public string Message + { + get { return message; } + set { message = value; } + } + } +} diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs index 066c961..967dca3 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs @@ -1,28 +1,28 @@ using System; -using System.Runtime.Serialization; using Tanshu.Accounts.Entities; using System.Collections.Generic; namespace Tanshu.Accounts.Contracts { - public class BillInventory + public class BillItemValue { public int ProductID { get; set; } public string Name { get; set; } public decimal Price { get; set; } public decimal Quantity { get; set; } - private decimal discount = 0; + private decimal _discount; + public Product Product { get; private set; } + public decimal Discount { - get { return discount; } + get { return _discount; } set { if (value < 0) throw new ArgumentException("Discount has to be non-negative greater than or equal to zero."); - else if (value > 1) + if (value > 1) throw new ArgumentException("Discount has to be less than one."); - else - discount = value; + _discount = value; } } @@ -31,7 +31,7 @@ namespace Tanshu.Accounts.Contracts { get { - return Quantity * Price * (1 - discount) * (1 + ServiceCharge) * Tax; + return Quantity * Price * (1 - _discount) * (1 + ServiceCharge) * Tax; } } @@ -40,7 +40,7 @@ namespace Tanshu.Accounts.Contracts { get { - return Quantity * Price * (1 - discount) * ServiceCharge; + return Quantity * Price * (1 - _discount) * ServiceCharge; } } @@ -48,7 +48,7 @@ namespace Tanshu.Accounts.Contracts { get { - return Quantity * Price * discount; + return Quantity * Price * _discount; } } @@ -56,17 +56,17 @@ namespace Tanshu.Accounts.Contracts { get { - return Quantity * Price * (1 - discount); + return Quantity * Price * (1 - _discount); } } - public bool Printed {get; set;} + public bool Printed { get; set; } public decimal Value { get { - return Price * Quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax); + return Price * Quantity * (1 - _discount) * (1 + ServiceCharge) * (1 + Tax); } } @@ -74,9 +74,9 @@ namespace Tanshu.Accounts.Contracts { get { - string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price); - if (discount != 0) - output += string.Format(" - {0:#.##%}", discount); + var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price); + if (_discount != 0) + output += string.Format(" - {0:#.##%}", _discount); foreach (var item in Modifiers) output += string.Format("\n\r -- {0}", item.Name); return output; @@ -94,11 +94,12 @@ namespace Tanshu.Accounts.Contracts return string.Format("{0} - {1}", ProductID, Name); } public IList Modifiers { get; set; } - public BillInventory() + public BillItemValue(Product product) { Quantity = 1; Printed = false; Modifiers = new List(); + Product = product; } } } diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs index 410127f..03545a7 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs @@ -1,23 +1,46 @@ using System; -using System.Runtime.Serialization; namespace Tanshu.Accounts.Contracts { + public enum BillItemType + { + Product, + Kot + } public class BillItemKey { - //Old = 0, New = 1, Modifiers = 2+ - public BillItemKey(int ProductID, int KotID) + private BillItemKey(int productID, int kotID, BillItemType billItemType) { - this.ProductID = ProductID; - this.KotID = KotID; + if (kotID < 0) + throw new ArgumentException("KotID Cannot be Negative"); + if (productID < 0) + throw new ArgumentException("ProductID Cannot be Negative"); + BillItemType = billItemType; + ProductID = productID; + KotID = kotID; + } + public BillItemKey(int kotID) + : this(0, kotID, BillItemType.Kot) + { } + public BillItemKey(int productID, int kotID) + : this(productID, kotID, BillItemType.Product) + { } + + private int _productID; + public int ProductID + { + get { return BillItemType == BillItemType.Product ? _productID : 0; } + private set { _productID = BillItemType == BillItemType.Product ? value : 0; } } - public int ProductID { get; private set; } public int KotID { get; private set; } + public BillItemType BillItemType { get; private set; } public override int GetHashCode() { - return ProductID.GetHashCode() ^ KotID.GetHashCode(); + return BillItemType == BillItemType.Product ? + ProductID.GetHashCode() ^ KotID.GetHashCode() ^ BillItemType.GetHashCode() + : KotID.GetHashCode() ^ BillItemType.GetHashCode(); ; } public override bool Equals(object obj) { @@ -41,7 +64,12 @@ namespace Tanshu.Accounts.Contracts if (!(b is BillItemKey)) return false; - return a.ProductID == b.ProductID && a.KotID == b.KotID; + if (a.BillItemType != b.BillItemType) + return false; + + return a.BillItemType == BillItemType.Product ? + a.ProductID == b.ProductID && a.KotID == b.KotID && a.BillItemType == b.BillItemType + : a.KotID == b.KotID && a.BillItemType == b.BillItemType; } public static bool operator !=(BillItemKey a, BillItemKey b) { diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs index d579965..725fb21 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs @@ -16,4 +16,11 @@ namespace Tanshu.Accounts.Contracts public virtual decimal Sale { get; set; } public virtual decimal NC { get; set; } } + public class BillDetail + { + public virtual DateTime Date { get; set; } + public virtual string BillID { get; set; } + public virtual string Settlement { get; set; } + public virtual decimal Amount { get; set; } + } } diff --git a/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs b/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs index f4d2146..0dcaea7 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts/ProductGroupBO.cs @@ -18,6 +18,7 @@ namespace Tanshu.Accounts.Entities public virtual decimal DiscountLimit { get; set; } public virtual bool IsModifierCompulsory { get; set; } public virtual string GroupType { get; set; } + [Inverse] public virtual IList Products { get; set; } } } \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs b/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs index feefecd..51f90cd 100644 --- a/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs +++ b/Tanshu.Accounts.Contracts/Helper Functions/EnumHelper.cs @@ -10,5 +10,15 @@ namespace Tanshu.Common.Helpers var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0]; return attribute != null ? attribute.Name : ""; } + public static bool Visible(this SettleOption settleOption) + { + var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0]; + return attribute != null ? attribute.ShowInChoices : false; + } + public static DisplayAttribute Attribute(this SettleOption settleOption) + { + var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0]; + return attribute; + } } } \ No newline at end of file diff --git a/Tanshu.Accounts.Contracts/RolesConstants.cs b/Tanshu.Accounts.Contracts/RolesConstants.cs index d9aa90e..3459bcf 100644 --- a/Tanshu.Accounts.Contracts/RolesConstants.cs +++ b/Tanshu.Accounts.Contracts/RolesConstants.cs @@ -32,9 +32,11 @@ namespace Tanshu.Accounts.Contracts public static RoleConstants MOVE_TABLE = new RoleConstants("Sales/MoveTable"); public static RoleConstants MERGE_KOT = new RoleConstants("Sales/MergeKot"); public static RoleConstants MOVE_KOT = new RoleConstants("Sales/MoveKot"); + public static RoleConstants OPEN_BILL = new RoleConstants("Sales/OpenBill"); public static RoleConstants PRINT_BILL = new RoleConstants("Sales/PrintBill"); public static RoleConstants PRINT_KOT = new RoleConstants("Sales/PrintKOT"); public static RoleConstants SALES = new RoleConstants("Sales/SalesBill"); + public static RoleConstants BILL_DETAILS = new RoleConstants("Sales/BillDetails"); public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis"); public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail"); public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill"); diff --git a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj index 3c0032b..a8f4542 100644 --- a/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj +++ b/Tanshu.Accounts.Contracts/Tanshu.Accounts.Contracts.csproj @@ -79,6 +79,7 @@ + diff --git a/Tanshu.Accounts.Helpers/ControlFactory.cs b/Tanshu.Accounts.Helpers/ControlFactory.cs index 73a39fb..1f82dee 100644 --- a/Tanshu.Accounts.Helpers/ControlFactory.cs +++ b/Tanshu.Accounts.Helpers/ControlFactory.cs @@ -56,17 +56,14 @@ namespace Tanshu.Accounts.Helpers if (stop < inList.Count) list.Add(new Product() { ProductID = stop, Name = "Next" }); - - - for (int i = 0; i < list.Count; i++) + for (var i = 0; i < list.Count; i++) { var item = list[i]; var control = GetButton(string.Format("p{0}", i), item.Units == string.Empty ? item.Name : string.Format("{0} ({1})", item.Name, item.Units), size.X, size.Y, item, bcDelegate); + if (item.SalePrice == 0) + control.BackColor = Color.Yellow; panel.Controls.Add(control); } - - - } // For Discount Form public static void GenerateGroups(ref FlowLayoutPanel panel, Point size, IList list, ButtonClickDelegate bcDelegate) diff --git a/Tanshu.Accounts.PointOfSale/Advances/frmAdjustAdvance.cs b/Tanshu.Accounts.PointOfSale/Advances/frmAdjustAdvance.cs index a9318ba..dbdc767 100644 --- a/Tanshu.Accounts.PointOfSale/Advances/frmAdjustAdvance.cs +++ b/Tanshu.Accounts.PointOfSale/Advances/frmAdjustAdvance.cs @@ -40,15 +40,11 @@ namespace Tanshu.Accounts.PointOfSale private void btnSelect_Click(object sender, EventArgs e) { - try - { var item = (Advance)dgExpenses.SelectedRows[0].DataBoundItem; txtCashier.Text = item.CashierIn.Name; txtNarration.Tag = item.AdvanceID; txtNarration.Text = item.Narration; txtAmount.Text = item.Amount.ToString(); - } - catch { } } private void btnAdjust_Click(object sender, EventArgs e) diff --git a/Tanshu.Accounts.PointOfSale/Advances/frmRecieveAdvance.cs b/Tanshu.Accounts.PointOfSale/Advances/frmRecieveAdvance.cs index 2869b09..76da931 100644 --- a/Tanshu.Accounts.PointOfSale/Advances/frmRecieveAdvance.cs +++ b/Tanshu.Accounts.PointOfSale/Advances/frmRecieveAdvance.cs @@ -24,7 +24,8 @@ namespace Tanshu.Accounts.PointOfSale Advance adv = new Advance(); adv.Narration = txtNarration.Text; adv.Amount = Convert.ToDecimal(txtAmount.Text.Trim()); - adv.CashierIn = UserBI.GetUser((int)txtCashier.Tag); + using (var bi = new UserBI()) + adv.CashierIn = bi.Get(x => x.UserID == (int)txtCashier.Tag); adv.DateIn = DateTime.Now; new AdvanceBI().Insert(adv); GridBind(); diff --git a/Tanshu.Accounts.PointOfSale/Authentication/KeyboardLogin.cs b/Tanshu.Accounts.PointOfSale/Authentication/KeyboardLogin.cs index 6255746..7929f9f 100644 --- a/Tanshu.Accounts.PointOfSale/Authentication/KeyboardLogin.cs +++ b/Tanshu.Accounts.PointOfSale/Authentication/KeyboardLogin.cs @@ -39,7 +39,8 @@ namespace Tanshu.Accounts.PointOfSale if (userName.Contains(":")) userName = userName.Substring(userName.IndexOf(":") + 1); - Session.User = UserBI.GetUserFromName(userName); + using (var bi = new UserBI()) + Session.User = bi.Get(x => x.Name == userName); } } diff --git a/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs b/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs index bd421a6..8a320ae 100644 --- a/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs +++ b/Tanshu.Accounts.PointOfSale/Authentication/LoginForm.cs @@ -40,7 +40,8 @@ namespace Tanshu.Accounts.PointOfSale private void btnLogin_Click(object sender, EventArgs e) { - _user = UserBI.ValidateUser(txtUserName.Text.Trim(), Tanshu.Common.Md5.Hash(txtPassword.Text, "v2")); + using (var bi = new UserBI()) + _user = bi.ValidateUser(txtUserName.Text.Trim(), Tanshu.Common.Md5.Hash(txtPassword.Text, "v2")); if (_user != null) this.Close(); else diff --git a/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs b/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs index 6e59517..8a3b5fa 100644 --- a/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs +++ b/Tanshu.Accounts.PointOfSale/Authentication/MsrLogin.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tanshu.Accounts.Repository; -using System.Threading; +using Tanshu.Accounts.Repository; using Tanshu.Accounts.Contracts; -using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale { @@ -16,15 +10,17 @@ namespace Tanshu.Accounts.PointOfSale { return LoginUser(true); } - bool LoginUser(bool setThreadPrincipal) + + static bool LoginUser(bool setThreadPrincipal) { using (var frm = new MsrLoginForm(false)) { string userName; frm.ShowDialog(); - bool authenticated = frm.UserName(out userName); + var authenticated = frm.UserName(out userName); if (authenticated && setThreadPrincipal) - SetThreadPrincipal(userName); + using (var bi = new UserBI()) + Session.User = bi.Get(x => x.Name == userName); return authenticated; } @@ -35,14 +31,5 @@ namespace Tanshu.Accounts.PointOfSale Session.User = null; return true; } - static void SetThreadPrincipal(string userName) - { - //log.Warn(string.Format("User Login: '{0}'", userName)); - if (userName.Contains(":")) - userName = userName.Substring(userName.IndexOf(":") + 1); - - Session.User = UserBI.GetUserFromName(userName); - } - } } diff --git a/Tanshu.Accounts.PointOfSale/Authentication/MsrLoginForm.cs b/Tanshu.Accounts.PointOfSale/Authentication/MsrLoginForm.cs index 25974a1..bde1557 100644 --- a/Tanshu.Accounts.PointOfSale/Authentication/MsrLoginForm.cs +++ b/Tanshu.Accounts.PointOfSale/Authentication/MsrLoginForm.cs @@ -7,14 +7,14 @@ namespace Tanshu.Accounts.PointOfSale { public partial class MsrLoginForm : Form { - private string loginString; - private User user; - private bool register; + private string _loginString; + private User _user; + private readonly bool register; public MsrLoginForm(bool register) { InitializeComponent(); - user = null; - loginString = string.Empty; + _user = null; + _loginString = string.Empty; this.register = register; this.btnLogin.Enabled = false; } @@ -23,33 +23,36 @@ namespace Tanshu.Accounts.PointOfSale { if (!register) { - var user = UserBI.MsrValidateUser(loginString); - - if (user != null) + using (var bi = new UserBI()) { - this.user = user; - this.Close(); + var user = bi.MsrValidateUser(_loginString); + + if (user != null) + { + this._user = user; + this.Close(); + } + else + MessageBox.Show("Unrecognised Card"); } - else - MessageBox.Show("Unrecognised Card"); } else { - this.user = new User() { Name = loginString }; + this._user = new User() { Name = _loginString }; this.Close(); } } public bool UserName(out string userName) { - userName = this.user == null ? "" : this.user.Name; - return this.user != null; + userName = this._user == null ? "" : this._user.Name; + return this._user != null; } private void MsrLoginForm_KeyPress(object sender, KeyPressEventArgs e) { btnLogin.Enabled = true; - this.loginString += e.KeyChar.ToString(); + this._loginString += e.KeyChar.ToString(); } } } diff --git a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs index 238be93..084a49a 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs @@ -14,52 +14,42 @@ namespace Tanshu.Accounts.PointOfSale { public class BillController { - private readonly OrderedDictionary bill = - new OrderedDictionary(); + private readonly OrderedDictionary _bill; private Voucher _billInfo; private Customer _customer = new CustomerBI().GetCustomer(1); private int? _editVoucherID; + private readonly bool _print; private ISaleForm _saleForm; - public BillController(int? editVoucherID) + public BillController(int? editVoucherID, bool print) { this._editVoucherID = editVoucherID; + _print = print; + _bill = new OrderedDictionary(); } - public BillInventory CurrentProduct + public BillItemValue CurrentProduct { get { if (_saleForm.BindingSource.Position == -1) return null; - else - { - var item = bill.ElementAt(_saleForm.BindingSource.Position); - if (item.Key.KotID == -1) - return null; - return item.Value; - } + var item = _bill.ElementAt(_saleForm.BindingSource.Position); + return item.Key.BillItemType == BillItemType.Product ? item.Value : null; } } - public BillInventory CurrentKot + public BillItemKey CurrentKot { get { if (_saleForm.BindingSource.Position == -1) return null; - else - { - KeyValuePair item = bill.ElementAt(_saleForm.BindingSource.Position); - if (item.Key.KotID != -1) - return null; - if (item.Key.ProductID == 0) - return null; - return item.Value; - } + var item = _bill.ElementAt(_saleForm.BindingSource.Position); + return item.Key.BillItemType == BillItemType.Kot ? item.Key : null; } } @@ -86,10 +76,9 @@ namespace Tanshu.Accounts.PointOfSale throw new NotImplementedException(); } - public void AddProductToGrid(int productID) + public void AddProductToGrid(Product product) { - new BillHelperFunctions(_saleForm.BindingSource, bill, productID).AddProduct(); - var product = ProductBI.GetProduct(productID); + AddProduct(product); if (ProductGroupModifierBI.HasCompulsoryModifier(product.ProductGroup.ProductGroupID)) { var item = CurrentProduct; @@ -98,7 +87,43 @@ namespace Tanshu.Accounts.PointOfSale ShowAmount(); } - public void ShowModifiers(int productGroupID, BillInventory item) + private void AddProduct(Product product) + { + var newKey = new BillItemKey(product.ProductID, 0); + + if (_bill.ContainsKey(newKey)) + { + _saleForm.BindingSource.CurrencyManager.Position = _bill.IndexOfKey(newKey); + _bill[newKey].Quantity += 1; + } + else + { + var billItemValue = new BillItemValue(product) + { + ProductID = product.ProductID, + Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")", + Price = product.SalePrice, + Tax = product.Tax.Rate, + ServiceCharge = product.ServiceCharge, + Discount = 0, + Printed = false, + Quantity = 1, + }; + + var old = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID).SingleOrDefault(); + if (old.Key != null) + { + billItemValue.Discount = old.Value.Discount; + billItemValue.Price = old.Value.Price; + } + _bill.Add(newKey, billItemValue); + _saleForm.BindingSource.DataSource = _bill.Values.ToList(); + _saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1; + } + } + + + public void ShowModifiers(int productGroupID, BillItemValue item) { if (item.Printed) return; @@ -116,28 +141,32 @@ namespace Tanshu.Accounts.PointOfSale if (!Session.IsAllowed(RoleConstants.DISCOUNT)) return; - var list = new ProductGroupBI().GetProductGroupTypes(); - using (var frm = new DiscountForm(list)) + using (var bi = new ProductGroupBI()) { - if (frm.ShowDialog() == DialogResult.OK) + using (var frm = new DiscountForm(bi.GetProductGroupTypes())) { - HashSet outList; - var discount = frm.Selection(out outList); - discount = discount / 100; - foreach (var item in bill) + if (frm.ShowDialog() == DialogResult.OK) { - if (item.Key.KotID == -1) - continue; - ProductGroup pg = new ProductGroupBI().GetProductGroupOfProduct(item.Value.ProductID); - if (outList.Contains(pg.GroupType)) - new BillHelperFunctions(_saleForm.BindingSource, bill, item.Value.ProductID).SetDiscount( - item.Value.Name, discount); + HashSet outList; + var discount = frm.Selection(out outList); + discount = discount / 100; + if (discount > 1 || discount < 0) + return; + + foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && outList.Contains(x.Value.Product.ProductGroup.GroupType))) + { + var product = item.Value.Product; + var maxDiscount = product.ProductGroup.DiscountLimit; + if (discount > item.Value.Product.ProductGroup.DiscountLimit) + MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", product.Name, maxDiscount), + "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning); + item.Value.Discount = discount; + } } } } ShowAmount(); } - public void ShowCustomerList(bool reset) { if ((_customer.CustomerID == 1) && (!reset)) @@ -198,14 +227,6 @@ namespace Tanshu.Accounts.PointOfSale } } - private static void PrintBill(int voucherID, int kotID) - { - if (kotID == 0) - Thermal.PrintBill(voucherID); - else - Thermal.PrintKot(voucherID, kotID); - } - private static List GetVoidReason(Dictionary filter) { var list = new List @@ -226,14 +247,14 @@ namespace Tanshu.Accounts.PointOfSale { //saleForm.BindingSource.CurrencyManager.Position = 1; - var taxAmount = bill.Values.Sum(b => b.TaxAmount); - var discountAmount = bill.Values.Sum(b => b.DiscountAmount); - var grossAmount = bill.Values.Sum(b => b.GrossAmount); - var valueAmount = bill.Values.Sum(b => b.Value); - var serviceChargeAmount = bill.Values.Sum(b => b.ServiceChargeAmount); + var taxAmount = _bill.Values.Sum(b => b.TaxAmount); + var discountAmount = _bill.Values.Sum(b => b.DiscountAmount); + var grossAmount = _bill.Values.Sum(b => b.GrossAmount); + var valueAmount = _bill.Values.Sum(b => b.Value); + var serviceChargeAmount = _bill.Values.Sum(b => b.ServiceChargeAmount); //bill.Values.ToList(); _saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount, - bill.Values.ToList()); + _bill.Values.ToList()); } public void ProductRemove() @@ -243,8 +264,8 @@ namespace Tanshu.Accounts.PointOfSale return; if (item.Printed) return; - bill.Remove(new BillItemKey(item.ProductID, 0)); - bill.ReCompact(); + _bill.Remove(new BillItemKey(item.ProductID, 0)); + _bill.ReCompact(); ShowAmount(); } @@ -253,28 +274,45 @@ namespace Tanshu.Accounts.PointOfSale var item = CurrentProduct; if (!Allowed(item)) return; - new BillHelperFunctions(_saleForm.BindingSource, bill, CurrentProduct.ProductID).SetQuantity(item, quantity, - prompt); + if (item.Printed) + return; + if (prompt && !GetInput("Quantity", ref quantity)) + return; + if (!prompt) + quantity += item.Quantity; + if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT)) + return; + var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product).Sum(x => x.Value.Quantity); + if (total < 0) + quantity -= total; + item.Quantity = quantity; ShowAmount(); } public void ChangeRate() { var item = CurrentProduct; - if (!Allowed(item)) + if (!Allowed(item, RoleConstants.CHANGE_RATE)) return; - new BillHelperFunctions(_saleForm.BindingSource, bill, CurrentProduct.ProductID).SetPrice(CurrentProduct); + var rate = item.Price; + if (!GetInput("Price", ref rate)) + return; + if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE)) + return; + foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID)) + sub.Value.Price = rate; + ShowAmount(); } - private bool Allowed(BillInventory item, RoleConstants role) + private bool Allowed(BillItemValue item, RoleConstants role) { if (item == null) return false; return Session.IsAllowed(role); } - private bool Allowed(BillInventory item) + private bool Allowed(BillItemValue item) { return item != null; } @@ -286,7 +324,7 @@ namespace Tanshu.Accounts.PointOfSale private void LoadBill(int voucherID) { ClearBill(); - bill.Clear(); + _bill.Clear(); _billInfo = null; _billInfo = VoucherBI.Get(voucherID); @@ -297,23 +335,23 @@ namespace Tanshu.Accounts.PointOfSale foreach (var kot in _billInfo.Kots) { - var kotKey = new BillItemKey(kot.KotID, -1); - var kotItem = new BillInventory + var kotKey = new BillItemKey(kot.KotID); + var kotItem = new BillItemValue(null) { ProductID = kot.KotID, Discount = 0, - Name = string.Format("Kot No.: {0} / KotID {1}", kot.KotID, kot.Code), + Name = string.Format("Kot: {0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name), Price = 0, Printed = true, Quantity = 0, Tax = -1, ServiceCharge = 0, }; - bill.Add(kotKey, kotItem); + _bill.Add(kotKey, kotItem); foreach (var inv in kot.Inventories) { var key = new BillItemKey(inv.Product.ProductID, kot.KotID); - var item = new BillInventory + var item = new BillItemValue(inv.Product) { ProductID = inv.Product.ProductID, Discount = inv.Discount, @@ -329,11 +367,11 @@ namespace Tanshu.Accounts.PointOfSale }; foreach (var mod in inv.InventoryModifier) item.Modifiers.Add(mod.Modifier); - bill.Add(key, item); + _bill.Add(key, item); } } - var newKotKey = new BillItemKey(0, -1); - var newKotItem = new BillInventory + var newKotKey = new BillItemKey(0); + var newKotItem = new BillItemValue(null) { ProductID = 0, Discount = 0, @@ -344,7 +382,7 @@ namespace Tanshu.Accounts.PointOfSale Tax = -1, ServiceCharge = 0, }; - bill.Add(newKotKey, newKotItem); + _bill.Add(newKotKey, newKotItem); ShowAmount(); } @@ -352,7 +390,9 @@ namespace Tanshu.Accounts.PointOfSale { if (!string.IsNullOrEmpty(tableName)) { - var table = new FoodTableBI().Get(tableName); + FoodTable table; + using (var bi = new FoodTableBI()) + table = bi.Get(x => x.Name == tableName); if (table != null && table.VoucherID != 0) { LoadBill(table.VoucherID); @@ -360,31 +400,20 @@ namespace Tanshu.Accounts.PointOfSale } else { - var result = InputBox.Show("Table Number", "0", InputBox_Validating); - if (result.OK) - { - var tableID = result.Text.Trim(); - if ((tableID != "C") && (tableID != "") && (!tableID.Contains("."))) - { - var table = new FoodTableBI().Get(tableName); - if (table != null && table.VoucherID != 0) - { - LoadBill(table.VoucherID); - } - } - else - ClearBill(); - } + var result = "0"; + if (GetInput("Table Number", ref result)) + LoadBillFromTable(result); + else + ClearBill(); } } public void CancelBillChanges() { - if (bill.Count != 0 && bill.Values.Any(i => i.Printed == false)) - if ( - MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo, - MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) - return; + if (_bill.Values.Any(i => i.Printed == false) && + MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo, + MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) + return; ClearBill(); } @@ -392,9 +421,9 @@ namespace Tanshu.Accounts.PointOfSale { _billInfo = null; ShowCustomerList(true); - bill.Clear(); - var newKotKey = new BillItemKey(0, -1); - var newKotItem = new BillInventory + _bill.Clear(); + var newKotKey = new BillItemKey(0); + var newKotItem = new BillItemValue(null) { ProductID = 0, Discount = 0, @@ -405,8 +434,8 @@ namespace Tanshu.Accounts.PointOfSale Tax = -1, ServiceCharge = 0, }; - bill.Add(newKotKey, newKotItem); - _saleForm.ClearBill(bill); + _bill.Add(newKotKey, newKotItem); + _saleForm.ClearBill(_bill); } public void FormLoad() @@ -427,7 +456,10 @@ namespace Tanshu.Accounts.PointOfSale if (!Session.IsAllowed(RoleConstants.SETTLE_BILL)) return; IDictionary options; - using (var frm = new SettleChoicesForm(_billInfo)) + var amount = (_billInfo.Settlements.Single(x => x.Settled == SettleOption.Amount).Amount + + _billInfo.Settlements.Single(x => x.Settled == SettleOption.RoundOff).Amount) * -1; + + using (var frm = new SettleChoicesForm(amount)) { frm.ShowDialog(); options = frm.OptionsChosen; @@ -438,76 +470,19 @@ namespace Tanshu.Accounts.PointOfSale ClearBill(); } - internal void MoveTable() - { - if (_billInfo == null) - return; - if (VoucherBI.IsBillPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)) - return; - var table = GetTableForMove(true); - if (table == null) - return; - LoadBill(table.VoucherID == 0 ? MoveTable(table) : MergeTable(table)); - } - - private int MoveTable(FoodTable table) - { - if (!Session.IsAllowed(RoleConstants.MOVE_TABLE)) - return 0; - return new FoodTableBI().Move(_billInfo.TableID, table); - } - - private int MergeTable(FoodTable table) - { - if (!Session.IsAllowed(RoleConstants.MERGE_TABLE)) - return 0; - var kots = bill.Where(x => x.Key.KotID == -1 && x.Key.ProductID != 0); - foreach (var item in kots) - MergeKot(item.Value, table); - VoucherBI.Delete(_billInfo.VoucherID); - return table.VoucherID; - } - - private static int MergeKot(BillInventory kot, FoodTable table) - { - if (!Session.IsAllowed(RoleConstants.MERGE_KOT)) - return 0; - return VoucherBI.MoveKot(kot.ProductID, table); - } - - private int MoveKot(BillInventory kot, FoodTable table) - { - if (!Session.IsAllowed(RoleConstants.MOVE_KOT)) - return 0; - CreateNewVoucherForKotMove(kot, table); - return MergeKot(kot, table); - } - - private void CreateNewVoucherForKotMove(BillInventory kot, FoodTable table) - { - var voucher = new Voucher - { - Customer = _billInfo.Customer, - TableID = table.Name, - Waiter = _billInfo.Waiter, - Printed = false, - Void = false, - Date = DateTime.Now, - Narration = "", - User = Session.User - }; - VoucherBI.Insert(voucher); - } - + #region Move Table(s) / Kot(s) private static FoodTable GetTableForMove(bool allowMerge) { - using (var frm = new frmMoveTable(new FoodTableBI().List(), allowMerge)) + using (var bi = new FoodTableBI()) { - frm.ShowDialog(); - if (frm.Selection != null) - return frm.Selection; + using (var frm = new MoveTableForm(bi.List(), allowMerge)) + { + frm.ShowDialog(); + if (frm.Selection != null) + return frm.Selection; + } + return null; } - return null; } internal void MergeKot() @@ -522,70 +497,124 @@ namespace Tanshu.Accounts.PointOfSale var table = GetTableForMove(true); if (table == null) return; - var count = bill.Keys.Count(x => x.KotID == -1 && x.ProductID != 0); + var kotCount = _bill.Keys.Count(x => x.BillItemType == BillItemType.Kot && x.KotID != 0); var voucherID = 0; - if (table.VoucherID == 0 && count > 1) + if (table.VoucherID == 0 && kotCount > 1) //Move Kot voucherID = MoveKot(kot, table); - else if (table.VoucherID == 0 && count == 1) + else if (table.VoucherID == 0 && kotCount == 1) //Move Table voucherID = MoveTable(table); - else if (table.VoucherID != 0 && count > 1) + else if (table.VoucherID != 0 && kotCount > 1) //Merge Kot voucherID = MergeKot(kot, table); - else if (table.VoucherID != 0 && count == 1) + else if (table.VoucherID != 0 && kotCount == 1) //Merge Table voucherID = MergeTable(table); if (voucherID != 0) LoadBill(voucherID); } + internal void MoveTable() + { + if (_billInfo == null) + return; + if (VoucherBI.IsBillPrinted(_billInfo.VoucherID) && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)) + return; + var table = GetTableForMove(true); + if (table == null) + return; + LoadBill(table.VoucherID == 0 ? MoveTable(table) : MergeTable(table)); + } + private int MoveKot(BillItemKey kot, FoodTable table) + { + if (!Session.IsAllowed(RoleConstants.MOVE_KOT)) + return 0; + var voucher = new Voucher + { + Customer = _billInfo.Customer, + TableID = table.Name, + Waiter = _billInfo.Waiter, + Printed = false, + Void = false, + Date = DateTime.Now, + Narration = "", + User = Session.User + }; + VoucherBI.Insert(voucher, true); + return VoucherBI.MergeKot(kot.KotID, voucher); + } + private static int MergeKot(BillItemKey kot, FoodTable table) + { + if (!Session.IsAllowed(RoleConstants.MERGE_KOT)) + return 0; + return VoucherBI.MergeKot(kot.KotID, table); + } + private int MoveTable(FoodTable table) + { + if (!Session.IsAllowed(RoleConstants.MOVE_TABLE)) + return 0; + using (var ft = new FoodTableBI()) + return ft.Move(_billInfo.TableID, table); + } + private int MergeTable(FoodTable table) + { + if (!Session.IsAllowed(RoleConstants.MERGE_TABLE)) + return 0; + var kots = _bill.Keys.Where(x => x.BillItemType == BillItemType.Kot && x.KotID != 0); + foreach (var item in kots) + MergeKot(item, table); + VoucherBI.Delete(_billInfo.VoucherID); + return table.VoucherID; + } + #endregion #region Save - // if (btnWaiter.Tag == null) - //btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID; - - public void Save(bool print, int waiterID, string tableID) + public void SaveBill(int waiterID, string tableID) { - if (print && !Session.IsAllowed(RoleConstants.PRINT_BILL)) - return; - if (!print && !Session.IsAllowed(RoleConstants.PRINT_KOT)) + if (!Session.IsAllowed(RoleConstants.PRINT_BILL)) return; if ((_billInfo != null) && (VoucherBI.IsBillPrinted(_billInfo.VoucherID)) && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))) return; - if (bill.Count == 1) //new kot only + if (_bill.Count == 1) //new kot only return; - if (print) - ShowDiscount(); - int? saved; - if (_billInfo == null) - saved = InsertVoucher(print, waiterID, tableID); - else - saved = UpdateSale(print, waiterID, tableID); + ShowDiscount(); + var saved = _billInfo == null ? InsertVoucher(true, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(true, waiterID, tableID, !_editVoucherID.HasValue); + + if (!_editVoucherID.HasValue || _print) + Thermal.PrintBill(_billInfo.VoucherID); if (_editVoucherID.HasValue) _saleForm.CloseWindow(); - else - { - int kotID = 0; - if (!print && saved.HasValue) - kotID = saved.Value; - if (print || kotID != 0) - PrintBill(_billInfo.VoucherID, kotID); - } ClearBill(); } - private int? InsertVoucher(bool finalBill, int waiterID, string tableID) + public void SaveKot(int waiterID, string tableID) + { + if (!Session.IsAllowed(RoleConstants.PRINT_KOT)) + return; + if ((_billInfo != null) && (VoucherBI.IsBillPrinted(_billInfo.VoucherID)) && + (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL))) + return; + if (_bill.Count == 1) //new kot only + return; + var saved = _billInfo == null ? InsertVoucher(false, waiterID, tableID, !_editVoucherID.HasValue) : UpdateVoucher(false, waiterID, tableID, !_editVoucherID.HasValue); + + if ((!_editVoucherID.HasValue || _print) && saved.HasValue) + Thermal.PrintKot(_billInfo.VoucherID, saved.Value); + + if (_editVoucherID.HasValue) + _saleForm.CloseWindow(); + ClearBill(); + } + + private int? InsertVoucher(bool finalBill, int waiterID, string tableID, bool updateTable) { if (_billInfo != null) { MessageBox.Show("Error in InsertVoucher, there is a previous sale in memory", "Error"); return null; } - - #region Voucher - _billInfo = new Voucher { Customer = _customer, @@ -598,24 +627,15 @@ namespace Tanshu.Accounts.PointOfSale Narration = "", User = Session.User }; - - #endregion - - #region Inventories - - Kot kot = GetKotForBill(); + UpdateKots(); + var kot = GetKotForBill(); if (kot != null) _billInfo.Kots.Add(kot); - - #endregion - - return VoucherBI.Insert(_billInfo); + return VoucherBI.Insert(_billInfo, updateTable); } - private int? UpdateSale(bool finalBill, int waiterID, string tableID) + private int? UpdateVoucher(bool finalBill, int waiterID, string tableID, bool updateTable) { - #region Voucher - _billInfo.User = Session.User; _billInfo.Customer = _customer; if (!_billInfo.Printed && finalBill) @@ -623,51 +643,62 @@ namespace Tanshu.Accounts.PointOfSale _billInfo.Printed = _billInfo.Printed || finalBill; _billInfo.TableID = tableID; _billInfo.Waiter = WaiterBI.GetWaiter(waiterID); - Kot kot = GetKotForBill(); + UpdateKots(); + var kot = GetKotForBill(); if (kot != null) _billInfo.Kots.Add(kot); - - #endregion - - #region Inventory - - #endregion - - return VoucherBI.Update(_billInfo); + return VoucherBI.Update(_billInfo, updateTable); + } + private void UpdateKots() + { + foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != 0)) + { + var i = _billInfo.Kots.Single(x => x.KotID == item.Key.KotID).Inventories.Single(x => x.Product.ProductID == item.Key.ProductID); + i.Discount = item.Value.Discount; + i.Rate = item.Value.Price; + } } - private Kot GetKotForBill() { var kot = new Kot(); - foreach (var item in bill) + foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == 0 && x.Value.Quantity != 0)) { - if (item.Key.KotID == -1 || item.Value.Quantity == 0) - continue; - else if (item.Key.KotID != 0) - { - Kot oldKot = _billInfo.Kots.Where(x => x.KotID == item.Key.KotID).Single(); - Inventory inv = oldKot.Inventories.Where(x => x.Product.ProductID == item.Key.ProductID).Single(); - inv.Rate = item.Value.Price; - inv.Discount = item.Value.Discount; - } - else - { - var temp = new Inventory(); - temp.Product = ProductBI.GetProduct(item.Key.ProductID); - temp.Quantity = item.Value.Quantity; - temp.Rate = item.Value.Price; - temp.Discount = item.Value.Discount; - temp.ServiceCharge = item.Value.ServiceCharge; - temp.Tax = item.Value.Tax; - foreach (Modifier mod in item.Value.Modifiers) - temp.InventoryModifier.Add(new InventoryModifier { Modifier = mod }); - kot.Inventories.Add(temp); - } + var inv = new Inventory + { + Product = item.Value.Product, + Quantity = item.Value.Quantity, + Rate = item.Value.Price, + Discount = item.Value.Discount, + ServiceCharge = item.Value.ServiceCharge, + Tax = item.Value.Tax + }; + foreach (var mod in item.Value.Modifiers) + inv.InventoryModifier.Add(new InventoryModifier { Modifier = mod }); + kot.Inventories.Add(inv); } - if (kot.Inventories.Count == 0) - return null; - else - return kot; + return kot.Inventories.Count == 0 ? null : kot; + } + + #endregion + #region InputBox + private bool GetInput(string prompt, ref decimal amount) + { + var result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating); + if (!result.OK) + return false; + if (!decimal.TryParse(result.Text, out amount)) + return false; + return true; + } + private bool GetInput(string prompt, ref string info) + { + var result = InputBox.Show(prompt, info, InputBox_Validating); + if (!result.OK) + return false; + info = result.Text.Trim(); + if (string.IsNullOrEmpty(info)) + return false; + return true; } #endregion diff --git a/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs b/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs index baa9104..9975e52 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/ISaleForm.cs @@ -10,10 +10,10 @@ namespace Tanshu.Accounts.PointOfSale { public interface ISaleForm { - void ClearBill(OrderedDictionary bill); + void ClearBill(OrderedDictionary bill); void SetCustomerDisplay(string name); void CloseWindow(); - void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List bill); + void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List bill); void ShowInfo(string billID, string kotID, DateTime creationDate, DateTime date, DateTime lastEditDate, string customer, string tableID, int waiterID, string waiter); void SetUserName(string name); BindingSource BindingSource { get; } diff --git a/Tanshu.Accounts.PointOfSale/CurrencyCounter.cs b/Tanshu.Accounts.PointOfSale/CurrencyCounter.cs index 16515b4..1b91293 100644 --- a/Tanshu.Accounts.PointOfSale/CurrencyCounter.cs +++ b/Tanshu.Accounts.PointOfSale/CurrencyCounter.cs @@ -50,7 +50,7 @@ namespace Tanshu.Accounts.PointOfSale } catch (Exception ex) { - System.Windows.Forms.MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message); + MessageBox.Show("Error Number " + ex.Source + "\n\r" + ex.Message); } } diff --git a/Tanshu.Accounts.PointOfSale/MainForm.cs b/Tanshu.Accounts.PointOfSale/MainForm.cs index d0bc733..79a110d 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.cs @@ -1,18 +1,29 @@ using System; +using System.Text.RegularExpressions; using System.Windows.Forms; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities.Auth; using Tanshu.Accounts.Helpers; using Tanshu.Accounts.PointOfSale.Sales; using Tanshu.Accounts.Repository; +using Tanshu.Common; using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale { + public enum LoginType + { + Keyboard, + Msr + } public partial class MainForm : Form { public MainForm() { + //using (var frm = new SplashForm()) + // frm.ShowDialog(); + + SessionManager.Initialize(); InitializeComponent(); } @@ -33,27 +44,27 @@ namespace Tanshu.Accounts.PointOfSale private void btnLogin_Click(object sender, EventArgs e) { - LoginUser(true); + LoginUser(LoginType.Keyboard); } private void btnSale_Click(object sender, EventArgs e) { if (Session.IsAllowed(RoleConstants.SALES)) - using (var frmSale = new SalesForm(new BillController(null))) + using (var frmSale = new SalesForm(new BillController(null, true))) frmSale.ShowDialog(); } private void btnProduct_Click(object sender, EventArgs e) { if (Session.IsAllowed(RoleConstants.PRODUCTS)) - using (var frm = new ProductsForm()) + using (var frm = new ProductListForm()) frm.ShowDialog(); } private void btnProductGroup_Click(object sender, EventArgs e) { if (Session.IsAllowed(RoleConstants.PRODUCTS)) - using (var frm = new ProductTypes()) + using (var frm = new ProductGroupListForm()) frm.ShowDialog(); } @@ -96,10 +107,13 @@ namespace Tanshu.Accounts.PointOfSale private void btnCreateUser_Click(object sender, EventArgs e) { if (Session.IsAllowed(RoleConstants.SECURITY_MANAGE_ROLES)) - using (var form = new SelectUser(UserBI.GetFilteredUsers, true)) + using (var bi = new UserBI()) { - form.userEvent += form_userEvent; - form.ShowDialog(); + using (var form = new SelectUser(bi.GetFilteredUsers, true)) + { + form.userEvent += form_userEvent; + form.ShowDialog(); + } } } @@ -155,6 +169,8 @@ namespace Tanshu.Accounts.PointOfSale btnProduct.Visible = Session.IsAllowed(RoleConstants.PRODUCTS); btnProductGroup.Visible = Session.IsAllowed(RoleConstants.PRODUCTS); + btnOpenBill.Visible = Session.IsAllowed(RoleConstants.OPEN_BILL); + btnCustomer.Visible = Session.IsAllowed(RoleConstants.CUSTOMERS); btnAdvanceReceive.Visible = Session.IsAllowed(RoleConstants.RECEIVE_ADVANCE); @@ -170,6 +186,8 @@ namespace Tanshu.Accounts.PointOfSale btnSaleAnalysis.Visible = Session.IsAllowed(RoleConstants.SALE_ANALYSIS); btnSaleDetail.Visible = Session.IsAllowed(RoleConstants.SALE_DETAIL); + btnBillDetails.Visible = Session.IsAllowed(RoleConstants.BILL_DETAILS); + btnChangePassword.Visible = Session.IsAuthenticated; } @@ -182,16 +200,23 @@ namespace Tanshu.Accounts.PointOfSale private void btnSwipeLogin_Click(object sender, EventArgs e) { - LoginUser(false); + LoginUser(LoginType.Msr); } - private void LoginUser(bool keyboard) + private void LoginUser(LoginType loginType) { ILogin login; - if (keyboard) - login = new KeyboardLogin(); - else - login = new MsrLogin(); + switch (loginType) + { + case LoginType.Keyboard: + login = new KeyboardLogin(); + break; + case LoginType.Msr: + login = new MsrLogin(); + break; + default: + return; + } if (!Session.IsAuthenticated) { @@ -211,5 +236,34 @@ namespace Tanshu.Accounts.PointOfSale } CheckRoles(); } + + private void btnOpenBill_Click(object sender, EventArgs e) + { + if (!Session.IsAllowed(RoleConstants.OPEN_BILL)) + return; + var result = InputBox.Show("Bill Number", "0", InputBox_Validating); + if (!result.OK) + return; + var voucher = VoucherBI.Get(result.Text); + if (Session.IsAllowed(RoleConstants.SALES)) + using (var frmSale = new SalesForm(new BillController(voucher.VoucherID, true))) + frmSale.ShowDialog(); + } + + private static void InputBox_Validating(object sender, InputBoxValidatingArgs e) + { + if (Regex.IsMatch(e.Text, @"^\d+-\d\d\d\d")) return; + e.Cancel = true; + e.Message = "Bill No should be in format ##-####"; + } + + private void btnBillDetails_Click(object sender, EventArgs e) + { + if (Session.IsAllowed(RoleConstants.BILL_DETAILS)) + using (var frm = new BillDetailsForm()) + frm.ShowDialog(); + } + + } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs index 0c90f7a..7f56a40 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs @@ -32,9 +32,11 @@ this.btnSale = new System.Windows.Forms.Button(); this.btnInitial = new System.Windows.Forms.Button(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnSwipeLogin = new System.Windows.Forms.Button(); this.btnCustomer = new System.Windows.Forms.Button(); this.btnProduct = new System.Windows.Forms.Button(); this.btnProductGroup = new System.Windows.Forms.Button(); + this.btnOpenBill = new System.Windows.Forms.Button(); this.btnAdvanceReceive = new System.Windows.Forms.Button(); this.btnAdvanceAdjust = new System.Windows.Forms.Button(); this.btnCreateUser = new System.Windows.Forms.Button(); @@ -43,9 +45,9 @@ this.btnCashierCheckout = new System.Windows.Forms.Button(); this.btnSaleAnalysis = new System.Windows.Forms.Button(); this.btnSaleDetail = new System.Windows.Forms.Button(); + this.btnBillDetails = new System.Windows.Forms.Button(); this.btnChangePassword = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button(); - this.btnSwipeLogin = new System.Windows.Forms.Button(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -88,6 +90,7 @@ this.flowLayoutPanel1.Controls.Add(this.btnCustomer); this.flowLayoutPanel1.Controls.Add(this.btnProduct); this.flowLayoutPanel1.Controls.Add(this.btnProductGroup); + this.flowLayoutPanel1.Controls.Add(this.btnOpenBill); this.flowLayoutPanel1.Controls.Add(this.btnAdvanceReceive); this.flowLayoutPanel1.Controls.Add(this.btnAdvanceAdjust); this.flowLayoutPanel1.Controls.Add(this.btnCreateUser); @@ -96,6 +99,7 @@ this.flowLayoutPanel1.Controls.Add(this.btnCashierCheckout); this.flowLayoutPanel1.Controls.Add(this.btnSaleAnalysis); this.flowLayoutPanel1.Controls.Add(this.btnSaleDetail); + this.flowLayoutPanel1.Controls.Add(this.btnBillDetails); this.flowLayoutPanel1.Controls.Add(this.btnChangePassword); this.flowLayoutPanel1.Controls.Add(this.btnExit); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -104,6 +108,16 @@ this.flowLayoutPanel1.Size = new System.Drawing.Size(792, 537); this.flowLayoutPanel1.TabIndex = 0; // + // btnSwipeLogin + // + this.btnSwipeLogin.Location = new System.Drawing.Point(315, 3); + this.btnSwipeLogin.Name = "btnSwipeLogin"; + this.btnSwipeLogin.Size = new System.Drawing.Size(150, 100); + this.btnSwipeLogin.TabIndex = 2; + this.btnSwipeLogin.Text = "Swipe Login"; + this.btnSwipeLogin.UseVisualStyleBackColor = true; + this.btnSwipeLogin.Click += new System.EventHandler(this.btnSwipeLogin_Click); + // // btnCustomer // this.btnCustomer.Location = new System.Drawing.Point(627, 3); @@ -134,116 +148,126 @@ this.btnProductGroup.UseVisualStyleBackColor = true; this.btnProductGroup.Click += new System.EventHandler(this.btnProductGroup_Click); // + // btnOpenBill + // + this.btnOpenBill.Location = new System.Drawing.Point(315, 109); + this.btnOpenBill.Name = "btnOpenBill"; + this.btnOpenBill.Size = new System.Drawing.Size(150, 100); + this.btnOpenBill.TabIndex = 7; + this.btnOpenBill.Text = "Open Bill"; + this.btnOpenBill.UseVisualStyleBackColor = true; + this.btnOpenBill.Click += new System.EventHandler(this.btnOpenBill_Click); + // // btnAdvanceReceive // - this.btnAdvanceReceive.Location = new System.Drawing.Point(315, 109); + this.btnAdvanceReceive.Location = new System.Drawing.Point(471, 109); this.btnAdvanceReceive.Name = "btnAdvanceReceive"; this.btnAdvanceReceive.Size = new System.Drawing.Size(150, 100); - this.btnAdvanceReceive.TabIndex = 7; + this.btnAdvanceReceive.TabIndex = 8; this.btnAdvanceReceive.Text = "Receive Advance"; this.btnAdvanceReceive.UseVisualStyleBackColor = true; this.btnAdvanceReceive.Click += new System.EventHandler(this.btnAdvanceReceive_Click); // // btnAdvanceAdjust // - this.btnAdvanceAdjust.Location = new System.Drawing.Point(471, 109); + this.btnAdvanceAdjust.Location = new System.Drawing.Point(627, 109); this.btnAdvanceAdjust.Name = "btnAdvanceAdjust"; this.btnAdvanceAdjust.Size = new System.Drawing.Size(150, 100); - this.btnAdvanceAdjust.TabIndex = 8; + this.btnAdvanceAdjust.TabIndex = 9; this.btnAdvanceAdjust.Text = "Adjust Advance"; this.btnAdvanceAdjust.UseVisualStyleBackColor = true; this.btnAdvanceAdjust.Click += new System.EventHandler(this.btnAdvanceAdjust_Click); // // btnCreateUser // - this.btnCreateUser.Location = new System.Drawing.Point(627, 109); + this.btnCreateUser.Location = new System.Drawing.Point(3, 215); this.btnCreateUser.Name = "btnCreateUser"; this.btnCreateUser.Size = new System.Drawing.Size(150, 100); - this.btnCreateUser.TabIndex = 9; + this.btnCreateUser.TabIndex = 10; this.btnCreateUser.Text = "Create User"; this.btnCreateUser.UseVisualStyleBackColor = true; this.btnCreateUser.Click += new System.EventHandler(this.btnCreateUser_Click); // // btnUserRoles // - this.btnUserRoles.Location = new System.Drawing.Point(3, 215); + this.btnUserRoles.Location = new System.Drawing.Point(159, 215); this.btnUserRoles.Name = "btnUserRoles"; this.btnUserRoles.Size = new System.Drawing.Size(150, 100); - this.btnUserRoles.TabIndex = 10; + this.btnUserRoles.TabIndex = 11; this.btnUserRoles.Text = "Manage User Roles"; this.btnUserRoles.UseVisualStyleBackColor = true; this.btnUserRoles.Click += new System.EventHandler(this.btnUserRoles_Click); // // btnGroupRoles // - this.btnGroupRoles.Location = new System.Drawing.Point(159, 215); + this.btnGroupRoles.Location = new System.Drawing.Point(315, 215); this.btnGroupRoles.Name = "btnGroupRoles"; this.btnGroupRoles.Size = new System.Drawing.Size(150, 100); - this.btnGroupRoles.TabIndex = 11; + this.btnGroupRoles.TabIndex = 12; this.btnGroupRoles.Text = "Manage Group Roles"; this.btnGroupRoles.UseVisualStyleBackColor = true; this.btnGroupRoles.Click += new System.EventHandler(this.btnGroupRoles_Click); // // btnCashierCheckout // - this.btnCashierCheckout.Location = new System.Drawing.Point(315, 215); + this.btnCashierCheckout.Location = new System.Drawing.Point(471, 215); this.btnCashierCheckout.Name = "btnCashierCheckout"; this.btnCashierCheckout.Size = new System.Drawing.Size(150, 100); - this.btnCashierCheckout.TabIndex = 12; + this.btnCashierCheckout.TabIndex = 13; this.btnCashierCheckout.Text = "Cashier Checkout"; this.btnCashierCheckout.UseVisualStyleBackColor = true; this.btnCashierCheckout.Click += new System.EventHandler(this.btnCashierCheckout_Click); // // btnSaleAnalysis // - this.btnSaleAnalysis.Location = new System.Drawing.Point(471, 215); + this.btnSaleAnalysis.Location = new System.Drawing.Point(627, 215); this.btnSaleAnalysis.Name = "btnSaleAnalysis"; this.btnSaleAnalysis.Size = new System.Drawing.Size(150, 100); - this.btnSaleAnalysis.TabIndex = 13; + this.btnSaleAnalysis.TabIndex = 14; this.btnSaleAnalysis.Text = "Sale Analysis"; this.btnSaleAnalysis.UseVisualStyleBackColor = true; this.btnSaleAnalysis.Click += new System.EventHandler(this.btnSaleAnalysis_Click); // // btnSaleDetail // - this.btnSaleDetail.Location = new System.Drawing.Point(627, 215); + this.btnSaleDetail.Location = new System.Drawing.Point(3, 321); this.btnSaleDetail.Name = "btnSaleDetail"; this.btnSaleDetail.Size = new System.Drawing.Size(150, 100); - this.btnSaleDetail.TabIndex = 14; + this.btnSaleDetail.TabIndex = 15; this.btnSaleDetail.Text = "Sale Detail"; this.btnSaleDetail.UseVisualStyleBackColor = true; this.btnSaleDetail.Click += new System.EventHandler(this.btnSaleDetail_Click); // + // btnBillDetails + // + this.btnBillDetails.Location = new System.Drawing.Point(159, 321); + this.btnBillDetails.Name = "btnBillDetails"; + this.btnBillDetails.Size = new System.Drawing.Size(150, 100); + this.btnBillDetails.TabIndex = 16; + this.btnBillDetails.Text = "Bill Details"; + this.btnBillDetails.UseVisualStyleBackColor = true; + this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click); + // // btnChangePassword // - this.btnChangePassword.Location = new System.Drawing.Point(3, 321); + this.btnChangePassword.Location = new System.Drawing.Point(315, 321); this.btnChangePassword.Name = "btnChangePassword"; this.btnChangePassword.Size = new System.Drawing.Size(150, 100); - this.btnChangePassword.TabIndex = 15; + this.btnChangePassword.TabIndex = 17; this.btnChangePassword.Text = "Change Password"; this.btnChangePassword.UseVisualStyleBackColor = true; this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); // // btnExit // - this.btnExit.Location = new System.Drawing.Point(159, 321); + this.btnExit.Location = new System.Drawing.Point(471, 321); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(150, 100); - this.btnExit.TabIndex = 16; + this.btnExit.TabIndex = 18; this.btnExit.Text = "Exit"; this.btnExit.UseVisualStyleBackColor = true; this.btnExit.Click += new System.EventHandler(this.btnExit_Click); // - // btnSwipeLogin - // - this.btnSwipeLogin.Location = new System.Drawing.Point(315, 3); - this.btnSwipeLogin.Name = "btnSwipeLogin"; - this.btnSwipeLogin.Size = new System.Drawing.Size(150, 100); - this.btnSwipeLogin.TabIndex = 2; - this.btnSwipeLogin.Text = "Swipe Login"; - this.btnSwipeLogin.UseVisualStyleBackColor = true; - this.btnSwipeLogin.Click += new System.EventHandler(this.btnSwipeLogin_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -280,5 +304,7 @@ private System.Windows.Forms.Button btnGroupRoles; private System.Windows.Forms.Button btnSaleDetail; private System.Windows.Forms.Button btnSwipeLogin; + private System.Windows.Forms.Button btnOpenBill; + private System.Windows.Forms.Button btnBillDetails; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs new file mode 100644 index 0000000..7a21885 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs @@ -0,0 +1,279 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ProductForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.Label4 = new System.Windows.Forms.Label(); + this.bsProductGroups = new System.Windows.Forms.BindingSource(this.components); + this.Label7 = new System.Windows.Forms.Label(); + this.bsTax = new System.Windows.Forms.BindingSource(this.components); + this.label5 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.txtProductID = new System.Windows.Forms.TextBox(); + this.txtCode = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.txtUnits = new System.Windows.Forms.TextBox(); + this.txtName = new System.Windows.Forms.TextBox(); + this.txtSalePrice = new System.Windows.Forms.TextBox(); + this.cmbTax = new System.Windows.Forms.ComboBox(); + this.chkDiscontinued = new System.Windows.Forms.CheckBox(); + this.txtServiceCharge = new System.Windows.Forms.TextBox(); + this.btnAddProductGroup = new System.Windows.Forms.Button(); + this.cmbProductGroup = new System.Windows.Forms.ComboBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOk = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsTax)).BeginInit(); + this.SuspendLayout(); + // + // Label4 + // + this.Label4.AutoSize = true; + this.Label4.Location = new System.Drawing.Point(22, 67); + this.Label4.Name = "Label4"; + this.Label4.Size = new System.Drawing.Size(84, 13); + this.Label4.TabIndex = 59; + this.Label4.Text = "Sale Price / Tax"; + // + // bsProductGroups + // + this.bsProductGroups.DataSource = typeof(Tanshu.Accounts.Entities.ProductGroup); + // + // Label7 + // + this.Label7.AutoSize = true; + this.Label7.Location = new System.Drawing.Point(30, 120); + this.Label7.Name = "Label7"; + this.Label7.Size = new System.Drawing.Size(36, 13); + this.Label7.TabIndex = 33; + this.Label7.Text = "Group"; + // + // bsTax + // + this.bsTax.DataSource = typeof(Tanshu.Accounts.Entities.Tax); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(26, 93); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(80, 13); + this.label5.TabIndex = 84; + this.label5.Text = "Service Charge"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 15); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(94, 13); + this.label3.TabIndex = 86; + this.label3.Text = "Product ID / Code"; + // + // txtProductID + // + this.txtProductID.Location = new System.Drawing.Point(112, 12); + this.txtProductID.Name = "txtProductID"; + this.txtProductID.ReadOnly = true; + this.txtProductID.Size = new System.Drawing.Size(189, 20); + this.txtProductID.TabIndex = 87; + // + // txtCode + // + this.txtCode.AccessibleName = ""; + this.txtCode.Enabled = false; + this.txtCode.Location = new System.Drawing.Point(307, 12); + this.txtCode.Name = "txtCode"; + this.txtCode.Size = new System.Drawing.Size(96, 20); + this.txtCode.TabIndex = 88; + this.txtCode.WordWrap = false; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(36, 41); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(70, 13); + this.Label2.TabIndex = 89; + this.Label2.Text = "Name / Units"; + // + // txtUnits + // + this.txtUnits.AccessibleName = ""; + this.txtUnits.Location = new System.Drawing.Point(307, 38); + this.txtUnits.Name = "txtUnits"; + this.txtUnits.Size = new System.Drawing.Size(96, 20); + this.txtUnits.TabIndex = 91; + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(112, 38); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(189, 20); + this.txtName.TabIndex = 90; + // + // txtSalePrice + // + this.txtSalePrice.AccessibleName = ""; + this.txtSalePrice.Location = new System.Drawing.Point(112, 64); + this.txtSalePrice.Name = "txtSalePrice"; + this.txtSalePrice.Size = new System.Drawing.Size(189, 20); + this.txtSalePrice.TabIndex = 92; + this.txtSalePrice.Text = "0"; + // + // cmbTax + // + this.cmbTax.DataSource = this.bsTax; + this.cmbTax.DisplayMember = "Name"; + this.cmbTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbTax.Location = new System.Drawing.Point(307, 65); + this.cmbTax.Name = "cmbTax"; + this.cmbTax.Size = new System.Drawing.Size(96, 21); + this.cmbTax.TabIndex = 93; + this.cmbTax.ValueMember = "TaxID"; + // + // chkDiscontinued + // + this.chkDiscontinued.AutoSize = true; + this.chkDiscontinued.Location = new System.Drawing.Point(307, 92); + this.chkDiscontinued.Name = "chkDiscontinued"; + this.chkDiscontinued.Size = new System.Drawing.Size(88, 17); + this.chkDiscontinued.TabIndex = 94; + this.chkDiscontinued.Text = "Discontinued"; + this.chkDiscontinued.UseVisualStyleBackColor = true; + // + // txtServiceCharge + // + this.txtServiceCharge.AccessibleName = "Phone 1"; + this.txtServiceCharge.Location = new System.Drawing.Point(112, 90); + this.txtServiceCharge.Name = "txtServiceCharge"; + this.txtServiceCharge.Size = new System.Drawing.Size(189, 20); + this.txtServiceCharge.TabIndex = 95; + this.txtServiceCharge.Text = "0"; + // + // btnAddProductGroup + // + this.btnAddProductGroup.Location = new System.Drawing.Point(307, 116); + this.btnAddProductGroup.Name = "btnAddProductGroup"; + this.btnAddProductGroup.Size = new System.Drawing.Size(96, 21); + this.btnAddProductGroup.TabIndex = 97; + this.btnAddProductGroup.Text = "Add Group"; + // + // cmbProductGroup + // + this.cmbProductGroup.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProductGroups, "ProductGroupID", true)); + this.cmbProductGroup.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProductGroups, "Name", true)); + this.cmbProductGroup.DataSource = this.bsProductGroups; + this.cmbProductGroup.DisplayMember = "Name"; + this.cmbProductGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbProductGroup.Location = new System.Drawing.Point(112, 116); + this.cmbProductGroup.Name = "cmbProductGroup"; + this.cmbProductGroup.Size = new System.Drawing.Size(189, 21); + this.cmbProductGroup.TabIndex = 96; + this.cmbProductGroup.ValueMember = "ProductGroupID"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(328, 143); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 99; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(247, 143); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 98; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // ProductForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(415, 230); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.btnAddProductGroup); + this.Controls.Add(this.cmbProductGroup); + this.Controls.Add(this.chkDiscontinued); + this.Controls.Add(this.txtServiceCharge); + this.Controls.Add(this.Label7); + this.Controls.Add(this.txtSalePrice); + this.Controls.Add(this.label5); + this.Controls.Add(this.cmbTax); + this.Controls.Add(this.txtUnits); + this.Controls.Add(this.txtName); + this.Controls.Add(this.Label2); + this.Controls.Add(this.txtCode); + this.Controls.Add(this.txtProductID); + this.Controls.Add(this.label3); + this.Controls.Add(this.Label4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Products"; + this.Load += new System.EventHandler(this.Products_Load); + ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsTax)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.Label Label4; + internal System.Windows.Forms.Label Label7; + private System.Windows.Forms.BindingSource bsProductGroups; + private System.Windows.Forms.BindingSource bsTax; + internal System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtProductID; + internal System.Windows.Forms.TextBox txtCode; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.TextBox txtUnits; + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.TextBox txtSalePrice; + internal System.Windows.Forms.ComboBox cmbTax; + private System.Windows.Forms.CheckBox chkDiscontinued; + internal System.Windows.Forms.TextBox txtServiceCharge; + internal System.Windows.Forms.Button btnAddProductGroup; + internal System.Windows.Forms.ComboBox cmbProductGroup; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOk; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs new file mode 100644 index 0000000..8a9df92 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Windows.Forms; +using Tanshu.Accounts.Helpers; +using Tanshu.Accounts.Contracts; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Entities.Auth; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ProductForm : Form + { + private int? _productID; + public ProductForm(int? productID) + { + _productID = productID; + InitializeComponent(); + } + + private void Products_Load(object sender, EventArgs e) + { + FillCombos(); + if (_productID.HasValue) + { + Product product; + using (var bi = new ProductBI()) + product = bi.Get(x => x.ProductID == _productID.Value); + txtProductID.Text = _productID.Value.ToString(); + txtCode.Text = product.Code.ToString(); + txtName.Text = product.Name; + txtUnits.Text = product.Units; + txtSalePrice.Text = product.SalePrice.ToString("#.##"); + cmbTax.SelectedValue = product.Tax.TaxID; + txtServiceCharge.Text = product.ServiceCharge.ToString("#.##"); + chkDiscontinued.Checked = product.Discontinued; + cmbProductGroup.SelectedValue = product.ProductGroup.ProductGroupID; + } + else + { + txtProductID.Text = "(Auto)"; + txtName.Focus(); + } + } + + private void FillCombos() + { + using (var bi = new ProductGroupBI()) + bsProductGroups.DataSource = bi.List(); + using (var bi = new TaxBI()) + bsTax.DataSource = bi.List(); + } + + private void btnAddCategory_Click(object sender, EventArgs e) + { + using (var frm = new ProductGroupListForm()) + frm.ShowDialog(); + FillCombos(); + cmbProductGroup.SelectedIndex = -1; + } + + private Product IsFormValid() + { + var product = new Product(); + + if (_productID.HasValue) + product.ProductID = _productID.Value; + + int code; + if (!int.TryParse(txtCode.Text, out code)) + return null; + if (code < 0) + return null; + product.Code = code; + + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return null; + product.Name = txtName.Text.Trim(); + if (string.IsNullOrEmpty(txtUnits.Text.Trim())) + return null; + product.Units = txtUnits.Text.Trim(); + + decimal salePrice; + if (!decimal.TryParse(txtSalePrice.Text, out salePrice)) + return null; + if (salePrice < 0) + return null; + product.SalePrice = salePrice; + + // Tax + if (cmbTax.SelectedItem == null) + return null; + product.Tax = (Tax)cmbTax.SelectedItem; + + decimal serviceCharge; + if (!decimal.TryParse(txtServiceCharge.Text, out serviceCharge)) + return null; + if (serviceCharge < 0 || serviceCharge > 1) + return null; + product.ServiceCharge = serviceCharge; + + product.Discontinued = chkDiscontinued.Checked; + + //Group + if (cmbProductGroup.SelectedItem == null) + return null; + product.ProductGroup = (ProductGroup)cmbProductGroup.SelectedItem; + return product; + } + + private void btnOk_Click(object sender, EventArgs e) + { + var product = IsFormValid(); + if (product != null) + { + using (var bi = new ProductBI()) + if (_productID.HasValue) + bi.Update(product); + else + bi.Insert(product); + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + else + MessageBox.Show("The form is not valid"); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.resx b/Tanshu.Accounts.PointOfSale/Products/ProductForm.resx similarity index 96% rename from Tanshu.Accounts.PointOfSale/Products/ProductsForm.resx rename to Tanshu.Accounts.PointOfSale/Products/ProductForm.resx index c9134b5..89e263b 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.resx +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - 211, 17 diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs new file mode 100644 index 0000000..eb89f91 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.Designer.cs @@ -0,0 +1,189 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ProductGroupForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtName = new System.Windows.Forms.TextBox(); + this.txtProductGroupID = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.Label1 = new System.Windows.Forms.Label(); + this.txtDiscountLimit = new System.Windows.Forms.TextBox(); + this.Label5 = new System.Windows.Forms.Label(); + this.chkModifierCompulsory = new System.Windows.Forms.CheckBox(); + this.txtGroupType = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(94, 38); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(267, 20); + this.txtName.TabIndex = 57; + // + // txtProductGroupID + // + this.txtProductGroupID.AccessibleName = "Unique ID"; + this.txtProductGroupID.Enabled = false; + this.txtProductGroupID.Location = new System.Drawing.Point(94, 12); + this.txtProductGroupID.Name = "txtProductGroupID"; + this.txtProductGroupID.ReadOnly = true; + this.txtProductGroupID.Size = new System.Drawing.Size(267, 20); + this.txtProductGroupID.TabIndex = 60; + this.txtProductGroupID.Text = "ProductGroupID"; + this.txtProductGroupID.WordWrap = false; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(53, 41); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(35, 13); + this.Label2.TabIndex = 58; + this.Label2.Text = "Name"; + // + // Label1 + // + this.Label1.AutoSize = true; + this.Label1.Location = new System.Drawing.Point(70, 15); + this.Label1.Name = "Label1"; + this.Label1.Size = new System.Drawing.Size(18, 13); + this.Label1.TabIndex = 59; + this.Label1.Text = "ID"; + // + // txtDiscountLimit + // + this.txtDiscountLimit.AccessibleName = "Phone 1"; + this.txtDiscountLimit.Location = new System.Drawing.Point(94, 64); + this.txtDiscountLimit.Name = "txtDiscountLimit"; + this.txtDiscountLimit.Size = new System.Drawing.Size(65, 20); + this.txtDiscountLimit.TabIndex = 72; + this.txtDiscountLimit.Text = "0"; + this.txtDiscountLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // Label5 + // + this.Label5.AutoSize = true; + this.Label5.Location = new System.Drawing.Point(15, 67); + this.Label5.Name = "Label5"; + this.Label5.Size = new System.Drawing.Size(73, 13); + this.Label5.TabIndex = 73; + this.Label5.Text = "Discount Limit"; + // + // chkModifierCompulsory + // + this.chkModifierCompulsory.AutoSize = true; + this.chkModifierCompulsory.Location = new System.Drawing.Point(94, 90); + this.chkModifierCompulsory.Name = "chkModifierCompulsory"; + this.chkModifierCompulsory.Size = new System.Drawing.Size(137, 17); + this.chkModifierCompulsory.TabIndex = 74; + this.chkModifierCompulsory.Text = "Is Modifier Compulsory?"; + this.chkModifierCompulsory.UseVisualStyleBackColor = true; + // + // txtGroupType + // + this.txtGroupType.AccessibleName = ""; + this.txtGroupType.Location = new System.Drawing.Point(94, 113); + this.txtGroupType.Name = "txtGroupType"; + this.txtGroupType.Size = new System.Drawing.Size(267, 20); + this.txtGroupType.TabIndex = 75; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(25, 116); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(63, 13); + this.label3.TabIndex = 76; + this.label3.Text = "Group Type"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(205, 139); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 77; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(286, 139); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 78; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // ProductGroupForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(373, 226); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.txtGroupType); + this.Controls.Add(this.label3); + this.Controls.Add(this.chkModifierCompulsory); + this.Controls.Add(this.txtDiscountLimit); + this.Controls.Add(this.Label5); + this.Controls.Add(this.txtName); + this.Controls.Add(this.txtProductGroupID); + this.Controls.Add(this.Label2); + this.Controls.Add(this.Label1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductGroupForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Product Types"; + this.Load += new System.EventHandler(this.ProductGroupForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.TextBox txtProductGroupID; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.Label Label1; + internal System.Windows.Forms.TextBox txtDiscountLimit; + internal System.Windows.Forms.Label Label5; + private System.Windows.Forms.CheckBox chkModifierCompulsory; + internal System.Windows.Forms.TextBox txtGroupType; + internal System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs new file mode 100644 index 0000000..6aed480 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.cs @@ -0,0 +1,81 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; +using System.Linq; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ProductGroupForm : Form + { + private int? _productGroupID; + public ProductGroupForm(int? productGroupID) + { + _productGroupID = productGroupID; + InitializeComponent(); + } + + private void ProductGroupForm_Load(object sender, EventArgs e) + { + if (_productGroupID.HasValue) + { + ProductGroup productGroup; + using (var bi = new ProductGroupBI()) + productGroup = bi.Get(x => x.ProductGroupID == _productGroupID.Value); + txtProductGroupID.Text = _productGroupID.Value.ToString(); + + txtName.Text = productGroup.Name; + txtDiscountLimit.Text = productGroup.DiscountLimit.ToString(); + chkModifierCompulsory.Checked = productGroup.IsModifierCompulsory; + txtGroupType.Text = productGroup.GroupType; + } + else + { + txtProductGroupID.Text = "(Auto)"; + txtName.Focus(); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnOk_Click(object sender, EventArgs e) + { + var productGroup = IsFormValid(); + if (productGroup != null) + { + using (var bi = new ProductGroupBI()) + if (_productGroupID.HasValue) + bi.Update(productGroup); + else + bi.Insert(productGroup); + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + else + MessageBox.Show("The form is not valid"); + } + private ProductGroup IsFormValid() + { + var productGroup = new ProductGroup(); + if (_productGroupID.HasValue) + productGroup.ProductGroupID = _productGroupID.Value; + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return null; + productGroup.Name = txtName.Text.Trim(); + decimal discount; + if (!decimal.TryParse(txtDiscountLimit.Text, out discount)) + return null; + if (discount < 0 || discount > 1) + return null; + productGroup.DiscountLimit = discount; + productGroup.IsModifierCompulsory = chkModifierCompulsory.Checked; + if (string.IsNullOrEmpty(txtGroupType.Text.Trim())) + return null; + productGroup.GroupType = txtGroupType.Text.Trim(); + return productGroup; + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductTypes.resx b/Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.resx similarity index 100% rename from Tanshu.Accounts.PointOfSale/Products/ProductTypes.resx rename to Tanshu.Accounts.PointOfSale/Products/ProductGroupForm.resx diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.Designer.cs new file mode 100644 index 0000000..66f4a24 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.Designer.cs @@ -0,0 +1,167 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ProductGroupListForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnEdit = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.dgvProductTypes = new System.Windows.Forms.DataGridView(); + this.bsList = new System.Windows.Forms.BindingSource(this.components); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.discountLimitDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductTypes)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); + this.SuspendLayout(); + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnAdd.Location = new System.Drawing.Point(12, 255); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 75); + this.btnAdd.TabIndex = 68; + this.btnAdd.Text = "&Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnEdit + // + this.btnEdit.AccessibleName = "Done"; + this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnEdit.Location = new System.Drawing.Point(93, 255); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(75, 75); + this.btnEdit.TabIndex = 62; + this.btnEdit.Text = "&Edit"; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnExit + // + this.btnExit.AccessibleName = "Done"; + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(286, 255); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 75); + this.btnExit.TabIndex = 61; + this.btnExit.Text = "E&xit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // dgvProductTypes + // + this.dgvProductTypes.AllowUserToAddRows = false; + this.dgvProductTypes.AllowUserToDeleteRows = false; + this.dgvProductTypes.AllowUserToResizeRows = false; + this.dgvProductTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvProductTypes.AutoGenerateColumns = false; + this.dgvProductTypes.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvProductTypes.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvProductTypes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nameDataGridViewTextBoxColumn, + this.discountLimitDataGridViewTextBoxColumn, + this.groupTypeDataGridViewTextBoxColumn}); + this.dgvProductTypes.DataSource = this.bsList; + this.dgvProductTypes.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dgvProductTypes.Location = new System.Drawing.Point(12, 12); + this.dgvProductTypes.MultiSelect = false; + this.dgvProductTypes.Name = "dgvProductTypes"; + this.dgvProductTypes.ReadOnly = true; + this.dgvProductTypes.RowHeadersVisible = false; + this.dgvProductTypes.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvProductTypes.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvProductTypes.Size = new System.Drawing.Size(349, 237); + this.dgvProductTypes.TabIndex = 74; + // + // bsList + // + this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.ProductGroup); + // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.ReadOnly = true; + this.nameDataGridViewTextBoxColumn.Width = 60; + // + // discountLimitDataGridViewTextBoxColumn + // + this.discountLimitDataGridViewTextBoxColumn.DataPropertyName = "DiscountLimit"; + dataGridViewCellStyle2.Format = "P0"; + dataGridViewCellStyle2.NullValue = null; + this.discountLimitDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.discountLimitDataGridViewTextBoxColumn.HeaderText = "Discount"; + this.discountLimitDataGridViewTextBoxColumn.Name = "discountLimitDataGridViewTextBoxColumn"; + this.discountLimitDataGridViewTextBoxColumn.ReadOnly = true; + this.discountLimitDataGridViewTextBoxColumn.Width = 74; + // + // groupTypeDataGridViewTextBoxColumn + // + this.groupTypeDataGridViewTextBoxColumn.DataPropertyName = "GroupType"; + this.groupTypeDataGridViewTextBoxColumn.HeaderText = "Type"; + this.groupTypeDataGridViewTextBoxColumn.Name = "groupTypeDataGridViewTextBoxColumn"; + this.groupTypeDataGridViewTextBoxColumn.ReadOnly = true; + this.groupTypeDataGridViewTextBoxColumn.Width = 56; + // + // ProductGroupListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(373, 342); + this.Controls.Add(this.dgvProductTypes); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.btnEdit); + this.Controls.Add(this.btnExit); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductGroupListForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Product Types"; + this.Load += new System.EventHandler(this.ProductGroupListForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductTypes)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnAdd; + internal System.Windows.Forms.Button btnEdit; + internal System.Windows.Forms.Button btnExit; + private System.Windows.Forms.DataGridView dgvProductTypes; + private System.Windows.Forms.BindingSource bsList; + private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.cs new file mode 100644 index 0000000..2b488ad --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ProductGroupListForm : Form + { + public ProductGroupListForm() + { + InitializeComponent(); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var frm = new ProductGroupForm(null)) + frm.ShowDialog(); + using (var bi = new ProductGroupBI()) + bsList.DataSource = bi.List(); + } + + private void ProductGroupListForm_Load(object sender, EventArgs e) + { + using (var bi = new ProductGroupBI()) + bsList.DataSource = bi.List(); + } + + private void btnEdit_Click(object sender, EventArgs e) + { + var id = ((ProductGroup)bsList.Current).ProductGroupID; + using (var frm = new ProductGroupForm(id)) + frm.ShowDialog(); + using (var bi = new ProductGroupBI()) + bsList.DataSource = bi.List(); + } + + private void btnExit_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.resx b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.resx new file mode 100644 index 0000000..c80ceb8 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductGroupListForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs new file mode 100644 index 0000000..e1ea39e --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs @@ -0,0 +1,229 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class ProductListForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnEdit = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.dgvProductTypes = new System.Windows.Forms.DataGridView(); + this.bsList = new System.Windows.Forms.BindingSource(this.components); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.unitsDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Tax = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Group = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.serviceChargeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.salePriceDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.discontinuedDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.sortOrderDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductTypes)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); + this.SuspendLayout(); + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnAdd.Location = new System.Drawing.Point(12, 255); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 75); + this.btnAdd.TabIndex = 68; + this.btnAdd.Text = "&Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnEdit + // + this.btnEdit.AccessibleName = "Done"; + this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnEdit.Location = new System.Drawing.Point(93, 255); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(75, 75); + this.btnEdit.TabIndex = 62; + this.btnEdit.Text = "&Edit"; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnExit + // + this.btnExit.AccessibleName = "Done"; + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(286, 255); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 75); + this.btnExit.TabIndex = 61; + this.btnExit.Text = "E&xit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // dgvProductTypes + // + this.dgvProductTypes.AllowUserToAddRows = false; + this.dgvProductTypes.AllowUserToDeleteRows = false; + this.dgvProductTypes.AllowUserToResizeRows = false; + this.dgvProductTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvProductTypes.AutoGenerateColumns = false; + this.dgvProductTypes.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvProductTypes.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvProductTypes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nameDataGridViewTextBoxColumn, + this.unitsDataGridViewTextBoxColumn, + this.Tax, + this.Group, + this.serviceChargeDataGridViewTextBoxColumn, + this.salePriceDataGridViewTextBoxColumn, + this.discontinuedDataGridViewCheckBoxColumn, + this.sortOrderDataGridViewTextBoxColumn}); + this.dgvProductTypes.DataSource = this.bsList; + this.dgvProductTypes.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dgvProductTypes.Location = new System.Drawing.Point(12, 12); + this.dgvProductTypes.MultiSelect = false; + this.dgvProductTypes.Name = "dgvProductTypes"; + this.dgvProductTypes.ReadOnly = true; + this.dgvProductTypes.RowHeadersVisible = false; + this.dgvProductTypes.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvProductTypes.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvProductTypes.Size = new System.Drawing.Size(349, 237); + this.dgvProductTypes.TabIndex = 74; + this.dgvProductTypes.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvProductTypes_CellFormatting); + // + // bsList + // + this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Product); + // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.ReadOnly = true; + this.nameDataGridViewTextBoxColumn.Width = 60; + // + // unitsDataGridViewTextBoxColumn + // + this.unitsDataGridViewTextBoxColumn.DataPropertyName = "Units"; + this.unitsDataGridViewTextBoxColumn.HeaderText = "Units"; + this.unitsDataGridViewTextBoxColumn.Name = "unitsDataGridViewTextBoxColumn"; + this.unitsDataGridViewTextBoxColumn.ReadOnly = true; + this.unitsDataGridViewTextBoxColumn.Width = 56; + // + // Tax + // + this.Tax.DataPropertyName = "Tax"; + this.Tax.HeaderText = "Tax"; + this.Tax.Name = "Tax"; + this.Tax.ReadOnly = true; + this.Tax.Width = 50; + // + // Group + // + this.Group.DataPropertyName = "ProductGroup"; + this.Group.HeaderText = "ProductGroup"; + this.Group.Name = "Group"; + this.Group.ReadOnly = true; + this.Group.Width = 98; + // + // serviceChargeDataGridViewTextBoxColumn + // + this.serviceChargeDataGridViewTextBoxColumn.DataPropertyName = "ServiceCharge"; + dataGridViewCellStyle1.Format = "P0"; + this.serviceChargeDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; + this.serviceChargeDataGridViewTextBoxColumn.HeaderText = "SC"; + this.serviceChargeDataGridViewTextBoxColumn.Name = "serviceChargeDataGridViewTextBoxColumn"; + this.serviceChargeDataGridViewTextBoxColumn.ReadOnly = true; + this.serviceChargeDataGridViewTextBoxColumn.Width = 46; + // + // salePriceDataGridViewTextBoxColumn + // + this.salePriceDataGridViewTextBoxColumn.DataPropertyName = "SalePrice"; + dataGridViewCellStyle2.Format = "N0"; + this.salePriceDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.salePriceDataGridViewTextBoxColumn.HeaderText = "SalePrice"; + this.salePriceDataGridViewTextBoxColumn.Name = "salePriceDataGridViewTextBoxColumn"; + this.salePriceDataGridViewTextBoxColumn.ReadOnly = true; + this.salePriceDataGridViewTextBoxColumn.Width = 77; + // + // discontinuedDataGridViewCheckBoxColumn + // + this.discontinuedDataGridViewCheckBoxColumn.DataPropertyName = "Discontinued"; + this.discontinuedDataGridViewCheckBoxColumn.HeaderText = "Discontinued"; + this.discontinuedDataGridViewCheckBoxColumn.Name = "discontinuedDataGridViewCheckBoxColumn"; + this.discontinuedDataGridViewCheckBoxColumn.ReadOnly = true; + this.discontinuedDataGridViewCheckBoxColumn.Width = 75; + // + // sortOrderDataGridViewTextBoxColumn + // + this.sortOrderDataGridViewTextBoxColumn.DataPropertyName = "SortOrder"; + this.sortOrderDataGridViewTextBoxColumn.HeaderText = "SortOrder"; + this.sortOrderDataGridViewTextBoxColumn.Name = "sortOrderDataGridViewTextBoxColumn"; + this.sortOrderDataGridViewTextBoxColumn.ReadOnly = true; + this.sortOrderDataGridViewTextBoxColumn.Width = 77; + // + // ProductListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(373, 342); + this.Controls.Add(this.dgvProductTypes); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.btnEdit); + this.Controls.Add(this.btnExit); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProductListForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Products"; + this.Load += new System.EventHandler(this.ProductGroupListForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvProductTypes)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnAdd; + internal System.Windows.Forms.Button btnEdit; + internal System.Windows.Forms.Button btnExit; + private System.Windows.Forms.DataGridView dgvProductTypes; + private System.Windows.Forms.BindingSource bsList; + private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn productGroupDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn taxDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn unitsDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn Tax; + private System.Windows.Forms.DataGridViewTextBoxColumn Group; + private System.Windows.Forms.DataGridViewTextBoxColumn serviceChargeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn salePriceDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn discontinuedDataGridViewCheckBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn sortOrderDataGridViewTextBoxColumn; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs new file mode 100644 index 0000000..cbdb148 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class ProductListForm : Form + { + public ProductListForm() + { + InitializeComponent(); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var frm = new ProductForm(null)) + frm.ShowDialog(); + using (var bi = new ProductBI()) + bsList.DataSource = bi.List(); + } + + private void ProductGroupListForm_Load(object sender, EventArgs e) + { + using (var bi = new ProductBI()) + bsList.DataSource = bi.List(); + } + + private void btnEdit_Click(object sender, EventArgs e) + { + var id = ((Product)bsList.Current).ProductID; + using (var frm = new ProductForm(id)) + frm.ShowDialog(); + using (var bi = new ProductBI()) + bsList.DataSource = bi.List(); + } + + private void btnExit_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void dgvProductTypes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (e.Value == null) + return; + if (e.Value.ToString() == "Castle.Proxies.TaxProxy") + { + e.Value = ((Product)bsList[e.RowIndex]).Tax.Name; + } + else if (e.Value.ToString() == "Castle.Proxies.ProductGroupProxy") + { + e.Value = ((Product)bsList[e.RowIndex]).ProductGroup.Name; + } + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.resx b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.resx new file mode 100644 index 0000000..869a785 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + 17, 17 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductTypes.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductTypes.Designer.cs deleted file mode 100644 index 55c75c4..0000000 --- a/Tanshu.Accounts.PointOfSale/Products/ProductTypes.Designer.cs +++ /dev/null @@ -1,255 +0,0 @@ -namespace Tanshu.Accounts.PointOfSale -{ - partial class ProductTypes - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.chkMaintainStock = new System.Windows.Forms.CheckBox(); - this.chkInUse = new System.Windows.Forms.CheckBox(); - this.btnAdd = new System.Windows.Forms.Button(); - this.btnDelete = new System.Windows.Forms.Button(); - this.btnNavFirst = new System.Windows.Forms.Button(); - this.btnNavPrev = new System.Windows.Forms.Button(); - this.lblNavLocation = new System.Windows.Forms.Label(); - this.btnNavNext = new System.Windows.Forms.Button(); - this.btnLast = new System.Windows.Forms.Button(); - this.txtName = new System.Windows.Forms.TextBox(); - this.btnUpdate = new System.Windows.Forms.Button(); - this.btnExit = new System.Windows.Forms.Button(); - this.txtUniqueID = new System.Windows.Forms.TextBox(); - this.Label2 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.txtTaxRate = new System.Windows.Forms.TextBox(); - this.Label5 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // chkMaintainStock - // - this.chkMaintainStock.AutoSize = true; - this.chkMaintainStock.Location = new System.Drawing.Point(259, 85); - this.chkMaintainStock.Name = "chkMaintainStock"; - this.chkMaintainStock.Size = new System.Drawing.Size(89, 17); - this.chkMaintainStock.TabIndex = 71; - this.chkMaintainStock.Text = "For Purchase"; - this.chkMaintainStock.UseVisualStyleBackColor = true; - // - // chkInUse - // - this.chkInUse.AutoSize = true; - this.chkInUse.Location = new System.Drawing.Point(178, 86); - this.chkInUse.Name = "chkInUse"; - this.chkInUse.Size = new System.Drawing.Size(65, 17); - this.chkInUse.TabIndex = 70; - this.chkInUse.Text = "For Sale"; - this.chkInUse.UseVisualStyleBackColor = true; - // - // btnAdd - // - this.btnAdd.Location = new System.Drawing.Point(35, 117); - this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(75, 23); - this.btnAdd.TabIndex = 68; - this.btnAdd.Text = "&Add"; - this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); - // - // btnDelete - // - this.btnDelete.Location = new System.Drawing.Point(115, 117); - this.btnDelete.Name = "btnDelete"; - this.btnDelete.Size = new System.Drawing.Size(75, 23); - this.btnDelete.TabIndex = 69; - this.btnDelete.Text = "&Delete"; - // - // btnNavFirst - // - this.btnNavFirst.Location = new System.Drawing.Point(67, 147); - this.btnNavFirst.Name = "btnNavFirst"; - this.btnNavFirst.Size = new System.Drawing.Size(40, 23); - this.btnNavFirst.TabIndex = 63; - this.btnNavFirst.Text = "<<"; - // - // btnNavPrev - // - this.btnNavPrev.Location = new System.Drawing.Point(107, 147); - this.btnNavPrev.Name = "btnNavPrev"; - this.btnNavPrev.Size = new System.Drawing.Size(35, 23); - this.btnNavPrev.TabIndex = 64; - this.btnNavPrev.Text = "<"; - // - // lblNavLocation - // - this.lblNavLocation.BackColor = System.Drawing.Color.White; - this.lblNavLocation.Location = new System.Drawing.Point(139, 147); - this.lblNavLocation.Name = "lblNavLocation"; - this.lblNavLocation.Size = new System.Drawing.Size(95, 23); - this.lblNavLocation.TabIndex = 65; - this.lblNavLocation.Text = "No Records"; - this.lblNavLocation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnNavNext - // - this.btnNavNext.Location = new System.Drawing.Point(235, 147); - this.btnNavNext.Name = "btnNavNext"; - this.btnNavNext.Size = new System.Drawing.Size(35, 23); - this.btnNavNext.TabIndex = 66; - this.btnNavNext.Text = ">"; - // - // btnLast - // - this.btnLast.Location = new System.Drawing.Point(275, 147); - this.btnLast.Name = "btnLast"; - this.btnLast.Size = new System.Drawing.Size(40, 23); - this.btnLast.TabIndex = 67; - this.btnLast.Text = ">>"; - // - // txtName - // - this.txtName.AccessibleName = ""; - this.txtName.Location = new System.Drawing.Point(94, 48); - this.txtName.Name = "txtName"; - this.txtName.Size = new System.Drawing.Size(254, 20); - this.txtName.TabIndex = 57; - // - // btnUpdate - // - this.btnUpdate.AccessibleName = "Done"; - this.btnUpdate.Location = new System.Drawing.Point(195, 117); - this.btnUpdate.Name = "btnUpdate"; - this.btnUpdate.Size = new System.Drawing.Size(72, 24); - this.btnUpdate.TabIndex = 62; - this.btnUpdate.Text = "&Update"; - // - // btnExit - // - this.btnExit.AccessibleName = "Done"; - this.btnExit.Location = new System.Drawing.Point(273, 117); - this.btnExit.Name = "btnExit"; - this.btnExit.Size = new System.Drawing.Size(72, 24); - this.btnExit.TabIndex = 61; - this.btnExit.Text = "E&xit"; - // - // txtUniqueID - // - this.txtUniqueID.AccessibleName = "Unique ID"; - this.txtUniqueID.Enabled = false; - this.txtUniqueID.Location = new System.Drawing.Point(94, 13); - this.txtUniqueID.Name = "txtUniqueID"; - this.txtUniqueID.Size = new System.Drawing.Size(254, 20); - this.txtUniqueID.TabIndex = 60; - this.txtUniqueID.Text = "UniqueID"; - this.txtUniqueID.WordWrap = false; - // - // Label2 - // - this.Label2.AutoSize = true; - this.Label2.Location = new System.Drawing.Point(53, 48); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(35, 13); - this.Label2.TabIndex = 58; - this.Label2.Text = "Name"; - // - // Label1 - // - this.Label1.AutoSize = true; - this.Label1.Location = new System.Drawing.Point(33, 13); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(55, 13); - this.Label1.TabIndex = 59; - this.Label1.Text = "Unique ID"; - // - // txtTaxRate - // - this.txtTaxRate.AccessibleName = "Phone 1"; - this.txtTaxRate.Location = new System.Drawing.Point(94, 83); - this.txtTaxRate.Name = "txtTaxRate"; - this.txtTaxRate.Size = new System.Drawing.Size(65, 20); - this.txtTaxRate.TabIndex = 72; - this.txtTaxRate.Text = "0"; - this.txtTaxRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // Label5 - // - this.Label5.AutoSize = true; - this.Label5.Location = new System.Drawing.Point(15, 83); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(73, 13); - this.Label5.TabIndex = 73; - this.Label5.Text = "Discount Limit"; - // - // ProductTypes - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(373, 180); - this.Controls.Add(this.txtTaxRate); - this.Controls.Add(this.Label5); - this.Controls.Add(this.chkMaintainStock); - this.Controls.Add(this.chkInUse); - this.Controls.Add(this.btnAdd); - this.Controls.Add(this.btnDelete); - this.Controls.Add(this.btnNavFirst); - this.Controls.Add(this.btnNavPrev); - this.Controls.Add(this.lblNavLocation); - this.Controls.Add(this.btnNavNext); - this.Controls.Add(this.btnLast); - this.Controls.Add(this.txtName); - this.Controls.Add(this.btnUpdate); - this.Controls.Add(this.btnExit); - this.Controls.Add(this.txtUniqueID); - this.Controls.Add(this.Label2); - this.Controls.Add(this.Label1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ProductTypes"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Product Types"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - internal System.Windows.Forms.CheckBox chkMaintainStock; - internal System.Windows.Forms.CheckBox chkInUse; - internal System.Windows.Forms.Button btnAdd; - internal System.Windows.Forms.Button btnDelete; - internal System.Windows.Forms.Button btnNavFirst; - internal System.Windows.Forms.Button btnNavPrev; - internal System.Windows.Forms.Label lblNavLocation; - internal System.Windows.Forms.Button btnNavNext; - internal System.Windows.Forms.Button btnLast; - internal System.Windows.Forms.TextBox txtName; - internal System.Windows.Forms.Button btnUpdate; - internal System.Windows.Forms.Button btnExit; - internal System.Windows.Forms.TextBox txtUniqueID; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.TextBox txtTaxRate; - internal System.Windows.Forms.Label Label5; - } -} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductTypes.cs b/Tanshu.Accounts.PointOfSale/Products/ProductTypes.cs deleted file mode 100644 index 2b52561..0000000 --- a/Tanshu.Accounts.PointOfSale/Products/ProductTypes.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace Tanshu.Accounts.PointOfSale -{ - public partial class ProductTypes : Form - { - public ProductTypes() - { - InitializeComponent(); - } - - private void btnAdd_Click(object sender, EventArgs e) - { - - } - } -} diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductsForm.Designer.cs deleted file mode 100644 index bc084e6..0000000 --- a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.Designer.cs +++ /dev/null @@ -1,450 +0,0 @@ -namespace Tanshu.Accounts.PointOfSale -{ - partial class ProductsForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.Label4 = new System.Windows.Forms.Label(); - this.txtSalePrice = new System.Windows.Forms.TextBox(); - this.bsProducts = new System.Windows.Forms.BindingSource(this.components); - this.btnAddProductGroup = new System.Windows.Forms.Button(); - this.cmbProductGroup = new System.Windows.Forms.ComboBox(); - this.bsProductGroups = new System.Windows.Forms.BindingSource(this.components); - this.Label7 = new System.Windows.Forms.Label(); - this.txtName = new System.Windows.Forms.TextBox(); - this.Label2 = new System.Windows.Forms.Label(); - this.btnNavFirst = new System.Windows.Forms.Button(); - this.btnNavPrev = new System.Windows.Forms.Button(); - this.lblNavLocation = new System.Windows.Forms.Label(); - this.btnNavNext = new System.Windows.Forms.Button(); - this.btnLast = new System.Windows.Forms.Button(); - this.txtUniqueID = new System.Windows.Forms.TextBox(); - this.Label1 = new System.Windows.Forms.Label(); - this.btnAdd = new System.Windows.Forms.Button(); - this.btnDelete = new System.Windows.Forms.Button(); - this.btnUpdate = new System.Windows.Forms.Button(); - this.btnExit = new System.Windows.Forms.Button(); - this.chkDiscontinued = new System.Windows.Forms.CheckBox(); - this.cmbSalesTax = new System.Windows.Forms.ComboBox(); - this.bsTax = new System.Windows.Forms.BindingSource(this.components); - this.label5 = new System.Windows.Forms.Label(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.txtProductID = new System.Windows.Forms.TextBox(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - this.txtUnits = new System.Windows.Forms.TextBox(); - ((System.ComponentModel.ISupportInitialize)(this.bsProducts)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsTax)).BeginInit(); - this.tableLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); - this.SuspendLayout(); - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Location = new System.Drawing.Point(3, 105); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(84, 13); - this.Label4.TabIndex = 59; - this.Label4.Text = "Sale Price / Tax"; - // - // txtSalePrice - // - this.txtSalePrice.AccessibleName = ""; - this.txtSalePrice.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "SalePrice", true)); - this.txtSalePrice.Dock = System.Windows.Forms.DockStyle.Top; - this.txtSalePrice.Location = new System.Drawing.Point(106, 108); - this.txtSalePrice.Name = "txtSalePrice"; - this.txtSalePrice.Size = new System.Drawing.Size(149, 20); - this.txtSalePrice.TabIndex = 53; - this.txtSalePrice.Text = "0"; - // - // bsProducts - // - this.bsProducts.DataSource = typeof(Tanshu.Accounts.Entities.Product); - this.bsProducts.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.bsProducts_AddingNew); - this.bsProducts.PositionChanged += new System.EventHandler(this.bsProducts_PositionChanged); - // - // btnAddProductGroup - // - this.btnAddProductGroup.Dock = System.Windows.Forms.DockStyle.Top; - this.btnAddProductGroup.Location = new System.Drawing.Point(261, 73); - this.btnAddProductGroup.Name = "btnAddProductGroup"; - this.btnAddProductGroup.Size = new System.Drawing.Size(151, 21); - this.btnAddProductGroup.TabIndex = 37; - this.btnAddProductGroup.Text = "Add Group"; - this.btnAddProductGroup.Click += new System.EventHandler(this.btnAddCategory_Click); - // - // cmbProductGroup - // - this.cmbProductGroup.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "ProductGroup", true)); - this.cmbProductGroup.DataSource = this.bsProductGroups; - this.cmbProductGroup.DisplayMember = "Name"; - this.cmbProductGroup.Dock = System.Windows.Forms.DockStyle.Top; - this.cmbProductGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cmbProductGroup.Location = new System.Drawing.Point(106, 73); - this.cmbProductGroup.Name = "cmbProductGroup"; - this.cmbProductGroup.Size = new System.Drawing.Size(149, 21); - this.cmbProductGroup.TabIndex = 35; - this.cmbProductGroup.ValueMember = "ProductTypeID"; - // - // bsProductGroups - // - this.bsProductGroups.DataSource = typeof(Tanshu.Accounts.Entities.ProductGroup); - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Location = new System.Drawing.Point(3, 70); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(76, 13); - this.Label7.TabIndex = 33; - this.Label7.Text = "Product Group"; - // - // txtName - // - this.txtName.AccessibleName = ""; - this.txtName.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "Name", true)); - this.txtName.Dock = System.Windows.Forms.DockStyle.Top; - this.txtName.Location = new System.Drawing.Point(106, 38); - this.txtName.Name = "txtName"; - this.txtName.Size = new System.Drawing.Size(149, 20); - this.txtName.TabIndex = 0; - // - // Label2 - // - this.Label2.AutoSize = true; - this.Label2.Location = new System.Drawing.Point(3, 35); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(70, 13); - this.Label2.TabIndex = 28; - this.Label2.Text = "Name / Units"; - // - // btnNavFirst - // - this.btnNavFirst.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnNavFirst.Location = new System.Drawing.Point(3, 53); - this.btnNavFirst.Name = "btnNavFirst"; - this.btnNavFirst.Size = new System.Drawing.Size(97, 44); - this.btnNavFirst.TabIndex = 44; - this.btnNavFirst.Text = "<<"; - this.btnNavFirst.Click += new System.EventHandler(this.btnNavFirst_Click); - // - // btnNavPrev - // - this.btnNavPrev.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnNavPrev.Location = new System.Drawing.Point(106, 53); - this.btnNavPrev.Name = "btnNavPrev"; - this.btnNavPrev.Size = new System.Drawing.Size(97, 44); - this.btnNavPrev.TabIndex = 45; - this.btnNavPrev.Text = "<"; - this.btnNavPrev.Click += new System.EventHandler(this.btnNavPrev_Click); - // - // lblNavLocation - // - this.lblNavLocation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblNavLocation.BackColor = System.Drawing.Color.White; - this.lblNavLocation.Location = new System.Drawing.Point(12, 186); - this.lblNavLocation.Name = "lblNavLocation"; - this.lblNavLocation.Size = new System.Drawing.Size(391, 23); - this.lblNavLocation.TabIndex = 46; - this.lblNavLocation.Text = "No Records"; - this.lblNavLocation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblNavLocation.Click += new System.EventHandler(this.lblNavLocation_Click); - // - // btnNavNext - // - this.btnNavNext.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnNavNext.Location = new System.Drawing.Point(209, 53); - this.btnNavNext.Name = "btnNavNext"; - this.btnNavNext.Size = new System.Drawing.Size(97, 44); - this.btnNavNext.TabIndex = 47; - this.btnNavNext.Text = ">"; - this.btnNavNext.Click += new System.EventHandler(this.btnNavNext_Click); - // - // btnLast - // - this.btnLast.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnLast.Location = new System.Drawing.Point(312, 53); - this.btnLast.Name = "btnLast"; - this.btnLast.Size = new System.Drawing.Size(100, 44); - this.btnLast.TabIndex = 48; - this.btnLast.Text = ">>"; - this.btnLast.Click += new System.EventHandler(this.btnLast_Click); - // - // txtUniqueID - // - this.txtUniqueID.AccessibleName = ""; - this.txtUniqueID.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "Code", true)); - this.txtUniqueID.Dock = System.Windows.Forms.DockStyle.Top; - this.txtUniqueID.Enabled = false; - this.txtUniqueID.Location = new System.Drawing.Point(261, 3); - this.txtUniqueID.Name = "txtUniqueID"; - this.txtUniqueID.Size = new System.Drawing.Size(151, 20); - this.txtUniqueID.TabIndex = 37; - this.txtUniqueID.WordWrap = false; - // - // Label1 - // - this.Label1.AutoSize = true; - this.Label1.Location = new System.Drawing.Point(3, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(32, 13); - this.Label1.TabIndex = 36; - this.Label1.Text = "Code"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // btnAdd - // - this.btnAdd.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnAdd.Location = new System.Drawing.Point(3, 3); - this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(97, 44); - this.btnAdd.TabIndex = 72; - this.btnAdd.Text = "&Add"; - this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); - // - // btnDelete - // - this.btnDelete.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnDelete.Location = new System.Drawing.Point(106, 3); - this.btnDelete.Name = "btnDelete"; - this.btnDelete.Size = new System.Drawing.Size(97, 44); - this.btnDelete.TabIndex = 73; - this.btnDelete.Text = "&Delete"; - this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); - // - // btnUpdate - // - this.btnUpdate.AccessibleName = "Done"; - this.btnUpdate.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnUpdate.Location = new System.Drawing.Point(209, 3); - this.btnUpdate.Name = "btnUpdate"; - this.btnUpdate.Size = new System.Drawing.Size(97, 44); - this.btnUpdate.TabIndex = 71; - this.btnUpdate.Text = "&Update"; - this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); - // - // btnExit - // - this.btnExit.AccessibleName = "Done"; - this.btnExit.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnExit.Location = new System.Drawing.Point(312, 3); - this.btnExit.Name = "btnExit"; - this.btnExit.Size = new System.Drawing.Size(100, 44); - this.btnExit.TabIndex = 70; - this.btnExit.Text = "E&xit"; - this.btnExit.Click += new System.EventHandler(this.btnExit_Click); - // - // chkDiscontinued - // - this.chkDiscontinued.AutoSize = true; - this.chkDiscontinued.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.bsProducts, "Discontinued", true)); - this.chkDiscontinued.Dock = System.Windows.Forms.DockStyle.Top; - this.chkDiscontinued.Location = new System.Drawing.Point(261, 143); - this.chkDiscontinued.Name = "chkDiscontinued"; - this.chkDiscontinued.Size = new System.Drawing.Size(151, 17); - this.chkDiscontinued.TabIndex = 78; - this.chkDiscontinued.Text = "Discontinued"; - this.chkDiscontinued.UseVisualStyleBackColor = true; - // - // cmbSalesTax - // - this.cmbSalesTax.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "Tax", true)); - this.cmbSalesTax.DataSource = this.bsTax; - this.cmbSalesTax.DisplayMember = "Name"; - this.cmbSalesTax.Dock = System.Windows.Forms.DockStyle.Top; - this.cmbSalesTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cmbSalesTax.Location = new System.Drawing.Point(261, 108); - this.cmbSalesTax.Name = "cmbSalesTax"; - this.cmbSalesTax.Size = new System.Drawing.Size(151, 21); - this.cmbSalesTax.TabIndex = 82; - this.cmbSalesTax.ValueMember = "LedgerID"; - // - // bsTax - // - this.bsTax.DataSource = typeof(Tanshu.Accounts.Entities.Tax); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(3, 140); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(80, 13); - this.label5.TabIndex = 84; - this.label5.Text = "Service Charge"; - // - // textBox1 - // - this.textBox1.AccessibleName = "Phone 1"; - this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "ServiceCharge", true)); - this.textBox1.Dock = System.Windows.Forms.DockStyle.Top; - this.textBox1.Location = new System.Drawing.Point(106, 143); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(149, 20); - this.textBox1.TabIndex = 83; - this.textBox1.Text = "0"; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 3; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 37.5F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 37.5F)); - this.tableLayoutPanel1.Controls.Add(this.txtUnits, 2, 1); - this.tableLayoutPanel1.Controls.Add(this.txtProductID, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.chkDiscontinued, 2, 4); - this.tableLayoutPanel1.Controls.Add(this.label5, 0, 4); - this.tableLayoutPanel1.Controls.Add(this.txtSalePrice, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.textBox1, 1, 4); - this.tableLayoutPanel1.Controls.Add(this.btnAddProductGroup, 2, 2); - this.tableLayoutPanel1.Controls.Add(this.Label1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.cmbSalesTax, 2, 3); - this.tableLayoutPanel1.Controls.Add(this.cmbProductGroup, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.txtUniqueID, 2, 0); - this.tableLayoutPanel1.Controls.Add(this.Label7, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.Label2, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.txtName, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.Label4, 0, 3); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 5; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(415, 175); - this.tableLayoutPanel1.TabIndex = 85; - // - // txtProductID - // - this.txtProductID.AccessibleName = ""; - this.txtProductID.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "ProductID", true)); - this.txtProductID.Dock = System.Windows.Forms.DockStyle.Top; - this.txtProductID.Enabled = false; - this.txtProductID.Location = new System.Drawing.Point(106, 3); - this.txtProductID.Name = "txtProductID"; - this.txtProductID.Size = new System.Drawing.Size(149, 20); - this.txtProductID.TabIndex = 83; - this.txtProductID.WordWrap = false; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.ColumnCount = 4; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel2.Controls.Add(this.btnAdd, 0, 0); - this.tableLayoutPanel2.Controls.Add(this.btnDelete, 1, 0); - this.tableLayoutPanel2.Controls.Add(this.btnNavPrev, 1, 1); - this.tableLayoutPanel2.Controls.Add(this.btnLast, 3, 1); - this.tableLayoutPanel2.Controls.Add(this.btnNavNext, 2, 1); - this.tableLayoutPanel2.Controls.Add(this.btnNavFirst, 0, 1); - this.tableLayoutPanel2.Controls.Add(this.btnExit, 3, 0); - this.tableLayoutPanel2.Controls.Add(this.btnUpdate, 2, 0); - this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Bottom; - this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 212); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 2; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(415, 100); - this.tableLayoutPanel2.TabIndex = 86; - // - // txtUnits - // - this.txtUnits.AccessibleName = ""; - this.txtUnits.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "Units", true)); - this.txtUnits.Dock = System.Windows.Forms.DockStyle.Top; - this.txtUnits.Location = new System.Drawing.Point(261, 38); - this.txtUnits.Name = "txtUnits"; - this.txtUnits.Size = new System.Drawing.Size(151, 20); - this.txtUnits.TabIndex = 85; - // - // ProductsForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(415, 312); - this.Controls.Add(this.tableLayoutPanel2); - this.Controls.Add(this.tableLayoutPanel1); - this.Controls.Add(this.lblNavLocation); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ProductsForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Products"; - this.Load += new System.EventHandler(this.Products_Load); - ((System.ComponentModel.ISupportInitialize)(this.bsProducts)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bsTax)).EndInit(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.tableLayoutPanel2.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.TextBox txtSalePrice; - internal System.Windows.Forms.Button btnAddProductGroup; - internal System.Windows.Forms.ComboBox cmbProductGroup; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.TextBox txtName; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Button btnNavFirst; - internal System.Windows.Forms.Button btnNavPrev; - internal System.Windows.Forms.Label lblNavLocation; - internal System.Windows.Forms.Button btnNavNext; - internal System.Windows.Forms.Button btnLast; - internal System.Windows.Forms.TextBox txtUniqueID; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Button btnAdd; - internal System.Windows.Forms.Button btnDelete; - internal System.Windows.Forms.Button btnUpdate; - internal System.Windows.Forms.Button btnExit; - private System.Windows.Forms.CheckBox chkDiscontinued; - internal System.Windows.Forms.ComboBox cmbSalesTax; - private System.Windows.Forms.BindingSource bsProducts; - private System.Windows.Forms.BindingSource bsProductGroups; - private System.Windows.Forms.BindingSource bsTax; - internal System.Windows.Forms.Label label5; - internal System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - internal System.Windows.Forms.TextBox txtProductID; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; - internal System.Windows.Forms.TextBox txtUnits; - } -} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductsForm.cs deleted file mode 100644 index 8873a13..0000000 --- a/Tanshu.Accounts.PointOfSale/Products/ProductsForm.cs +++ /dev/null @@ -1,228 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Windows.Forms; -using Tanshu.Accounts.Helpers; -using Tanshu.Accounts.Contracts; -using Tanshu.Accounts.Repository; -using Tanshu.Accounts.Entities; -using Tanshu.Accounts.Entities.Auth; - -namespace Tanshu.Accounts.PointOfSale -{ - public partial class ProductsForm : Form - { - bool createOnly = false; - IList productList = new List(); - - #region Form Load - public ProductsForm() - { - InitializeComponent(); - } - - private void Products_Load(object sender, EventArgs e) - { - productList = ProductBI.GetProducts(); - bsProducts.DataSource = productList; - FillCombos(); - bsProducts.MoveFirst(); - } - - private void FillCombos() - { - bsProductGroups.DataSource = new ProductGroupBI().GetProductGroups(); - bsTax.DataSource = TaxBI.GetTaxes(); - } - #endregion - - #region Buttons - private void btnAdd_Click(object sender, EventArgs e) - { - if (btnAdd.Text == "&Add") - { - bsProducts.AddNew(); - LockControls(true); - this.lblNavLocation.Text = "Add New"; - txtName.Select(); - } - else - { - if (!ValidateValues()) - { - MessageBox.Show("Missing Information: Please check the form."); - bsProducts.CancelEdit(); - } - else - { - bsProducts.EndEdit(); - Save(true); - if (createOnly) - btnExit_Click(sender, e); - else - { - productList = ProductBI.GetProducts(); - bsProducts.DataSource = productList; - LockControls(false); - } - } - } - } - - private void btnDelete_Click(object sender, EventArgs e) - { - if (btnDelete.Text == "&Delete") - { - if (productList.Count() > 0) - { - if (MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) - { - if (ProductBI.Delete(productList.Single(p => p.Code == Convert.ToInt32(txtUniqueID.Text)).ProductID)) - { - productList = ProductBI.GetProducts(); - btnNavFirst_Click(sender, e); - } - } - } - } - - else - { - LockControls(false); - bsProducts.CancelEdit(); - } - - } - - private void btnUpdate_Click(object sender, EventArgs e) - { - if (MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) - { - Save(false); - bsProducts.ResetItem(bsProducts.Position); - } - } - #endregion - - #region Add / Edit / Delete - private bool ValidateValues() - { - if (txtName.Text.Trim().Length == 0) - return false; - if (cmbProductGroup.SelectedValue == null) - return false; - if (cmbSalesTax.SelectedValue == null) - return false; - return true; - } - - private bool Save(bool addNew) - { - #region Setup Products - Product product = new Product(); - if (!addNew) - product = (Product)bsProducts.Current; - product.Name = txtName.Text; - product.Units = txtUnits.Text; - product.ProductGroup = new ProductGroupBI().GetProductGroup((int)cmbProductGroup.SelectedValue); - product.SalePrice = Convert.ToDecimal(txtSalePrice.Text); - product.Discontinued = chkDiscontinued.Checked; - product.Tax = new Tax(); - if (addNew) - ProductBI.Insert(product); - else - ProductBI.Update(product); - - return true; - #endregion - } - #endregion - - private void btnExit_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void LockControls(bool enable) - { - if (enable) - { - btnAdd.Text = "&Save"; - btnDelete.Text = "&Cancel"; - } - else - { - btnAdd.Text = "&Add"; - btnDelete.Text = "&Delete"; - } - btnExit.Enabled = !enable; - btnLast.Enabled = !enable; - btnNavPrev.Enabled = !enable; - btnNavNext.Enabled = !enable; - btnUpdate.Enabled = !enable; - btnNavFirst.Enabled = !enable; - } - - private void btnAddCategory_Click(object sender, EventArgs e) - { - ProductTypes frm = new ProductTypes(); - frm.ShowDialog(); - frm.Dispose(); - FillCombos(); - cmbProductGroup.SelectedIndex = 0; - } - - - #region Move Buttons - private void btnNavFirst_Click(object sender, EventArgs e) - { - this.bsProducts.MoveFirst(); - } - private void btnNavPrev_Click(object sender, EventArgs e) - { - this.bsProducts.MovePrevious(); - } - private void btnNavNext_Click(object sender, EventArgs e) - { - this.bsProducts.MoveNext(); - } - private void btnLast_Click(object sender, EventArgs e) - { - this.bsProducts.MoveLast(); - } - private void lblNavLocation_Click(object sender, EventArgs e) - { - using (SelectProduct selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true)) - { - selectProduct.ShowDialog(); - if (selectProduct.SelectedItem != null) - { - bsProducts.Position = GetPosition(productList, selectProduct.SelectedItem.ProductID); - } - } - } - #endregion - #region Binding Source Events - private void bsProducts_AddingNew(object sender, AddingNewEventArgs e) - { - e.NewObject = new Product(); - } - - private void bsProducts_PositionChanged(object sender, EventArgs e) - { - this.lblNavLocation.Text = string.Format("{0} of {1}", bsProducts.Position + 1, bsProducts.Count); - } - #endregion - private int GetPosition(IList list, int id) - { - for (int i = 0; i < list.Count; i++) - { - if (list[i].ProductID == id) - return i; - } - return 0; - - } - } -} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Properties/Resources.Designer.cs b/Tanshu.Accounts.PointOfSale/Properties/Resources.Designer.cs new file mode 100644 index 0000000..dcaa3c9 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tanshu.Accounts.PointOfSale.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tanshu.Accounts.PointOfSale.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static System.Drawing.Bitmap Splash { + get { + object obj = ResourceManager.GetObject("Splash", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Properties/Resources.resx b/Tanshu.Accounts.PointOfSale/Properties/Resources.resx new file mode 100644 index 0000000..be8c994 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Splash.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs new file mode 100644 index 0000000..bd1b154 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Contracts; +using Tanshu.Accounts.Helpers; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class BillDetailsForm : Form + { + IList _list; + //private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public BillDetailsForm() + { + InitializeComponent(); + //log.Warn(string.Format("Sales Analysis by: {0}", Session.User.Name)); + } + + private void dtpStart_ValueChanged(object sender, EventArgs e) + { + ShowStatement(); + } + + private void ShowStatement() + { + _list = new SalesAnalysisBI().GetBillDetails(dtpStart.Value, dtpFinish.Value); + dgvSale.AutoGenerateColumns = true; + dgvSale.DataSource = _list; + dgvSale.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dgvSale.Columns[1].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0"; + dgvSale.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; + } + + private void dtpFinish_ValueChanged(object sender, EventArgs e) + { + ShowStatement(); + } + + private void Sale_Analysis_Form_Load(object sender, EventArgs e) + { + dtpStart.Value = DateTime.Today; + dtpFinish.Value = DateTime.Today; + ShowStatement(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs new file mode 100644 index 0000000..0def57d --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs @@ -0,0 +1,114 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class BillDetailsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dgvSale = new System.Windows.Forms.DataGridView(); + this.dtpFinish = new System.Windows.Forms.DateTimePicker(); + this.dtpStart = new System.Windows.Forms.DateTimePicker(); + this.label10 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit(); + this.SuspendLayout(); + // + // dgvSale + // + this.dgvSale.AllowUserToAddRows = false; + this.dgvSale.AllowUserToDeleteRows = false; + this.dgvSale.AllowUserToResizeRows = false; + this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvSale.Location = new System.Drawing.Point(12, 41); + this.dgvSale.MultiSelect = false; + this.dgvSale.Name = "dgvSale"; + this.dgvSale.ReadOnly = true; + this.dgvSale.RowHeadersVisible = false; + this.dgvSale.RowTemplate.Height = 19; + this.dgvSale.RowTemplate.ReadOnly = true; + this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvSale.Size = new System.Drawing.Size(335, 466); + this.dgvSale.TabIndex = 14; + // + // dtpFinish + // + this.dtpFinish.CustomFormat = "dd-MMM-yyyy"; + this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtpFinish.Location = new System.Drawing.Point(168, 12); + this.dtpFinish.Name = "dtpFinish"; + this.dtpFinish.Size = new System.Drawing.Size(90, 20); + this.dtpFinish.TabIndex = 21; + this.dtpFinish.ValueChanged += new System.EventHandler(this.dtpFinish_ValueChanged); + // + // dtpStart + // + this.dtpStart.CustomFormat = "dd-MMM-yyyy"; + this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtpStart.Location = new System.Drawing.Point(12, 12); + this.dtpStart.Name = "dtpStart"; + this.dtpStart.Size = new System.Drawing.Size(90, 20); + this.dtpStart.TabIndex = 20; + this.dtpStart.ValueChanged += new System.EventHandler(this.dtpStart_ValueChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(108, 16); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(54, 13); + this.label10.TabIndex = 22; + this.label10.Text = "<- Date ->"; + // + // BillDetailsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(359, 519); + this.Controls.Add(this.dgvSale); + this.Controls.Add(this.dtpFinish); + this.Controls.Add(this.dtpStart); + this.Controls.Add(this.label10); + this.MaximizeBox = false; + this.Name = "BillDetailsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sale Analysis Form"; + this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.DataGridView dgvSale; + private System.Windows.Forms.DateTimePicker dtpFinish; + private System.Windows.Forms.DateTimePicker dtpStart; + private System.Windows.Forms.Label label10; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.resx b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.resx similarity index 100% rename from Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.resx rename to Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.resx diff --git a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs index a210235..a937052 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs @@ -33,7 +33,8 @@ namespace Tanshu.Accounts.PointOfSale _loading = true; cmbCashier.DisplayMember = "Name"; cmbCashier.ValueMember = "UserID"; - cmbCashier.DataSource = UserBI.ListActive(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7)); + using (var bi = new UserBI()) + cmbCashier.DataSource = bi.ListActive(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7)); _loading = loading; } diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs index f357331..fba19df 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs @@ -53,5 +53,22 @@ namespace Tanshu.Accounts.PointOfSale var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5); Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate); } + + private void button2_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnExport_Click(object sender, EventArgs e) + { + if (_list == null) + return; + var data = string.Format("{0}\t{1}\t{2}\n", "Product", "Sale", "NC"); + foreach (var item in _list) + { + data += string.Format("{0}\t{1}\t{2}\n", item.Product, item.Sale, item.NC); + } + Clipboard.SetText(data,TextDataFormat.Text); + } } } diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs index 23ba3a8..a2d1b55 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs @@ -33,6 +33,8 @@ this.dtpStart = new System.Windows.Forms.DateTimePicker(); this.label10 = new System.Windows.Forms.Label(); this.btnPrint = new System.Windows.Forms.Button(); + this.btnExport = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit(); this.SuspendLayout(); // @@ -41,9 +43,6 @@ this.dgvSale.AllowUserToAddRows = false; this.dgvSale.AllowUserToDeleteRows = false; this.dgvSale.AllowUserToResizeRows = false; - this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvSale.Location = new System.Drawing.Point(12, 41); this.dgvSale.MultiSelect = false; @@ -53,7 +52,7 @@ this.dgvSale.RowTemplate.Height = 19; this.dgvSale.RowTemplate.ReadOnly = true; this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgvSale.Size = new System.Drawing.Size(335, 466); + this.dgvSale.Size = new System.Drawing.Size(335, 385); this.dgvSale.TabIndex = 14; // // dtpFinish @@ -87,20 +86,44 @@ // // btnPrint // - this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnPrint.Location = new System.Drawing.Point(272, 12); + this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnPrint.Location = new System.Drawing.Point(12, 432); this.btnPrint.Name = "btnPrint"; - this.btnPrint.Size = new System.Drawing.Size(75, 23); + this.btnPrint.Size = new System.Drawing.Size(75, 75); this.btnPrint.TabIndex = 28; this.btnPrint.Text = "Print"; this.btnPrint.UseVisualStyleBackColor = true; this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click); // - // frmSaleDetail + // btnExport + // + this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnExport.Location = new System.Drawing.Point(93, 432); + this.btnExport.Name = "btnExport"; + this.btnExport.Size = new System.Drawing.Size(75, 75); + this.btnExport.TabIndex = 29; + this.btnExport.Text = "Export"; + this.btnExport.UseVisualStyleBackColor = true; + this.btnExport.Click += new System.EventHandler(this.btnExport_Click); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.Location = new System.Drawing.Point(272, 432); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 75); + this.button2.TabIndex = 30; + this.button2.Text = "&Close"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // FrmSaleDetail // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(359, 519); + this.Controls.Add(this.button2); + this.Controls.Add(this.btnExport); this.Controls.Add(this.btnPrint); this.Controls.Add(this.dgvSale); this.Controls.Add(this.dtpFinish); @@ -124,5 +147,7 @@ private System.Windows.Forms.DateTimePicker dtpStart; private System.Windows.Forms.Label label10; private System.Windows.Forms.Button btnPrint; + private System.Windows.Forms.Button btnExport; + private System.Windows.Forms.Button button2; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Resources/Splash.jpg b/Tanshu.Accounts.PointOfSale/Resources/Splash.jpg new file mode 100644 index 0000000..60e697f Binary files /dev/null and b/Tanshu.Accounts.PointOfSale/Resources/Splash.jpg differ diff --git a/Tanshu.Accounts.PointOfSale/Sales/BillHelperFunctions.cs b/Tanshu.Accounts.PointOfSale/Sales/BillHelperFunctions.cs deleted file mode 100644 index 08e2992..0000000 --- a/Tanshu.Accounts.PointOfSale/Sales/BillHelperFunctions.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.Linq; -using System.Windows.Forms; -using Tanshu.Accounts.Contracts; -using Tanshu.Accounts.Repository; -using Tanshu.Common; - -namespace Tanshu.Accounts.PointOfSale.Sales -{ - public class BillHelperFunctions - { - private readonly OrderedDictionary bill; - private readonly BindingSource _bindingSource; - private readonly BillItemKey _newKey; - - public BillHelperFunctions(BindingSource bindingSource, OrderedDictionary bill, - int productID) - { - this._bindingSource = bindingSource; - this.bill = bill; - _newKey = new BillItemKey(productID, 0); - } - - public void SetDiscount(string name, decimal discount) - { - if (discount > 1 || discount < 0) - return; - decimal maxDiscount = VoucherBI.GetProductDiscountLimit(_newKey.ProductID); - if (discount > maxDiscount) - MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", name, maxDiscount), - "Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning); - foreach (var item in bill) - { - if (item.Value.ProductID == _newKey.ProductID) - item.Value.Discount = discount; - } - } - - public void SetPrice(BillInventory product) - { - if (!Allowed(product, RoleConstants.CHANGE_RATE)) - return; - decimal rate = product.Price; - if (!GetInput("Price", ref rate)) - return; - if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE)) - return; - foreach (var item in bill) - { - if (item.Value.ProductID == _newKey.ProductID) - item.Value.Price = rate; - } - } - - private void InputBox_Validating(object sender, InputBoxValidatingArgs e) - { - } - - private bool Allowed(BillInventory item, RoleConstants role) - { - if (item == null) - return false; - if (!Session.IsAllowed(role)) - return false; - return true; - } - - private bool GetInput(string prompt, ref decimal amount) - { - InputBoxResult result = InputBox.Show(prompt, amount.ToString(), InputBox_Validating); - if (!result.OK) - return false; - if (!decimal.TryParse(result.Text, out amount)) - return false; - return true; - } - - #region Add Product - - public BillInventory AddProduct() - { - BillInventory product; - if (bill.ContainsKey(_newKey)) - { - _bindingSource.CurrencyManager.Position = bill.IndexOfKey(_newKey); - product = bill[_newKey]; - product.Quantity += 1; - } - else - { - //Has only old - product = VoucherBI.GetDefaultSaleBillItem(_newKey.ProductID); - foreach (var item in bill) - { - if (item.Key.ProductID == _newKey.ProductID) - { - product.Discount = item.Value.Discount; - product.Price = item.Value.Price; - } - } - product = AddProduct(product); - } - return product; - } - - private BillInventory AddProduct(BillInventory product) - { - bill.Add(new BillItemKey(product.ProductID, 0), product); - _bindingSource.DataSource = bill.Values.ToList(); - _bindingSource.CurrencyManager.Position = _bindingSource.CurrencyManager.Count - 1; - return product; - } - - #endregion - - #region Quantity - - public void SetQuantity(BillInventory product, decimal quantity, bool prompt) - { - if (product.Printed) - return; - if (prompt && !GetInput("Price", ref quantity)) - return; - - if (!prompt) - quantity += product.Quantity; - SetQuantity(product, quantity); - } - - private void SetQuantity(BillInventory product, decimal quantity) - { - if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT)) - return; - var total = quantity + bill.Where(item => item.Value.ProductID == _newKey.ProductID).Sum(item => item.Value.Quantity); - - if (total < 0) - quantity -= total; - product.Quantity = quantity; - } - - #endregion - } -} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.Designer.cs similarity index 92% rename from Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.Designer.cs rename to Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.Designer.cs index ae8aae0..c507942 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.Designer.cs @@ -1,6 +1,6 @@ namespace Tanshu.Accounts.PointOfSale { - partial class frmMoveTable + partial class MoveTableForm { /// /// Required designer variable. @@ -40,7 +40,7 @@ this.flpTables.Size = new System.Drawing.Size(847, 492); this.flpTables.TabIndex = 7; // - // frmMoveTable + // MoveTableForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -48,10 +48,10 @@ this.Controls.Add(this.flpTables); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; - this.Name = "frmMoveTable"; + this.Name = "MoveTableForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Move Table / Kot"; - this.Load += new System.EventHandler(this.frmMoveTable_Load); + this.Load += new System.EventHandler(this.MoveTableForm_Load); this.ResumeLayout(false); } @@ -59,7 +59,5 @@ #endregion private System.Windows.Forms.FlowLayoutPanel flpTables; - - } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.cs b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs similarity index 51% rename from Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.cs rename to Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs index 9aab193..5f80c8d 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/frmMoveTable.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.cs @@ -1,66 +1,50 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.Contracts; -using Tanshu.Accounts.SqlDAO; using Tanshu.Accounts.Helpers; -using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale { - public partial class frmMoveTable : Form + public partial class MoveTableForm : Form { - private IList source; - private FoodTable selection; - private bool allowMerge; - public frmMoveTable(IList source, bool allowMerge) + private readonly IList _source; + private readonly bool _allowMerge; + public MoveTableForm(IList source, bool allowMerge) { InitializeComponent(); - this.source = source; - selection = null; - this.allowMerge = allowMerge; - } - public FoodTable Selection - { - get - { - return selection; - } - + _source = source; + Selection = null; + _allowMerge = allowMerge; } - private void frmMoveTable_Load(object sender, EventArgs e) + public FoodTable Selection { get; private set; } + + private void MoveTableForm_Load(object sender, EventArgs e) { - ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, source, new ButtonClickDelegate(tableButton_Click)); + ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), 0, _source, new ButtonClickDelegate(tableButton_Click)); } private void tableButton_Click(object sender, EventArgs e) { - Button button = sender as Button; + var button = sender as Button; if (button == null) return; var item = button.Tag as FoodTable; if (item.Name == "Previous" || item.Name == "Next") { - int start = item.FoodTableID; + var start = item.FoodTableID; if (start < 0) start = 0; - ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, source, new ButtonClickDelegate(tableButton_Click)); + ControlFactory.GenerateTables(ref flpTables, new Point(75, 75), start, _source, new ButtonClickDelegate(tableButton_Click)); } else { - if (item.Status != null && item.Status != string.Empty && !allowMerge) - { + if (!string.IsNullOrEmpty(item.Status) && !_allowMerge) MessageBox.Show("Cannot move to a running table", "Cannot Move", MessageBoxButtons.OK, MessageBoxIcon.Error); - } else if (MessageBox.Show(string.Format("Move selected table to table {0}", item.Name), "Move", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - selection = item; + Selection = item; this.Close(); } } diff --git a/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.resx b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Sales/MoveTableForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs index bf01b25..0617d4b 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.Designer.cs @@ -1,4 +1,7 @@ -namespace Tanshu.Accounts.PointOfSale.Sales +using System.Collections.Generic; +using Tanshu.Accounts.Entities; + +namespace Tanshu.Accounts.PointOfSale.Sales { partial class SalesForm { @@ -29,8 +32,8 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.label7 = new System.Windows.Forms.Label(); this.txtDiscount = new System.Windows.Forms.TextBox(); this.Label12 = new System.Windows.Forms.Label(); @@ -41,6 +44,8 @@ this.txtGrossTax = new System.Windows.Forms.TextBox(); this.dgvProducts = new System.Windows.Forms.DataGridView(); this.Display = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.bindingSource = new System.Windows.Forms.BindingSource(this.components); this.pnlBilling = new System.Windows.Forms.Panel(); this.flpMain = new System.Windows.Forms.FlowLayoutPanel(); this.flpGroup = new System.Windows.Forms.FlowLayoutPanel(); @@ -51,12 +56,14 @@ this.btnDiscount = new System.Windows.Forms.Button(); this.btnModifier = new System.Windows.Forms.Button(); this.btnWaiter = new System.Windows.Forms.Button(); - this.btnMoveTable = new System.Windows.Forms.Button(); this.btnPrintKot = new System.Windows.Forms.Button(); + this.btnMoveTable = new System.Windows.Forms.Button(); this.btnPrintBill = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); this.btnVoid = new System.Windows.Forms.Button(); this.btnSettle = new System.Windows.Forms.Button(); + this.btnMore = new System.Windows.Forms.Button(); + this.btnMoveKot = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.txtServiceCharge = new System.Windows.Forms.TextBox(); this.txtTableID = new System.Windows.Forms.TextBox(); @@ -72,16 +79,12 @@ this.txtBillID = new System.Windows.Forms.TextBox(); this.txtKotID = new System.Windows.Forms.TextBox(); this.btnCustomer = new System.Windows.Forms.Button(); - this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.bindingSource = new System.Windows.Forms.BindingSource(this.components); this.bsWaiter = new System.Windows.Forms.BindingSource(this.components); this.bsPending = new System.Windows.Forms.BindingSource(this.components); - this.btnMore = new System.Windows.Forms.Button(); - this.btnMoveKot = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); this.pnlBilling.SuspendLayout(); this.flpActions.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bsPending)).BeginInit(); this.SuspendLayout(); @@ -208,14 +211,30 @@ // this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; this.Display.DataPropertyName = "Display"; - dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.Display.DefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.Display.DefaultCellStyle = dataGridViewCellStyle1; this.Display.HeaderText = "Display"; this.Display.MinimumWidth = 250; this.Display.Name = "Display"; this.Display.ReadOnly = true; this.Display.Width = 250; // + // printedDataGridViewTextBoxColumn + // + this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity"; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; + dataGridViewCellStyle2.Format = "N2"; + this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.printedDataGridViewTextBoxColumn.HeaderText = "Printed"; + this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn"; + this.printedDataGridViewTextBoxColumn.ReadOnly = true; + this.printedDataGridViewTextBoxColumn.Width = 65; + // + // bindingSource + // + this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.BillItemValue); + // // pnlBilling // this.pnlBilling.AutoSize = true; @@ -353,16 +372,6 @@ this.btnWaiter.UseVisualStyleBackColor = true; this.btnWaiter.Click += new System.EventHandler(this.btnWaiter_Click); // - // btnMoveTable - // - this.btnMoveTable.Location = new System.Drawing.Point(570, 3); - this.btnMoveTable.Name = "btnMoveTable"; - this.btnMoveTable.Size = new System.Drawing.Size(75, 75); - this.btnMoveTable.TabIndex = 158; - this.btnMoveTable.Text = "Move Table"; - this.btnMoveTable.UseVisualStyleBackColor = true; - this.btnMoveTable.Click += new System.EventHandler(this.btnMoveTable_Click); - // // btnPrintKot // this.btnPrintKot.Location = new System.Drawing.Point(489, 3); @@ -373,6 +382,16 @@ this.btnPrintKot.UseVisualStyleBackColor = true; this.btnPrintKot.Click += new System.EventHandler(this.btnPrintKot_Click); // + // btnMoveTable + // + this.btnMoveTable.Location = new System.Drawing.Point(570, 3); + this.btnMoveTable.Name = "btnMoveTable"; + this.btnMoveTable.Size = new System.Drawing.Size(75, 75); + this.btnMoveTable.TabIndex = 158; + this.btnMoveTable.Text = "Move Table"; + this.btnMoveTable.UseVisualStyleBackColor = true; + this.btnMoveTable.Click += new System.EventHandler(this.btnMoveTable_Click); + // // btnPrintBill // this.btnPrintBill.Location = new System.Drawing.Point(651, 3); @@ -413,6 +432,26 @@ this.btnSettle.UseVisualStyleBackColor = true; this.btnSettle.Click += new System.EventHandler(this.btnSettle_Click); // + // btnMore + // + this.btnMore.Location = new System.Drawing.Point(3, 84); + this.btnMore.Name = "btnMore"; + this.btnMore.Size = new System.Drawing.Size(75, 75); + this.btnMore.TabIndex = 159; + this.btnMore.Text = "More"; + this.btnMore.UseVisualStyleBackColor = true; + this.btnMore.Click += new System.EventHandler(this.btnMore_Click); + // + // btnMoveKot + // + this.btnMoveKot.Location = new System.Drawing.Point(84, 84); + this.btnMoveKot.Name = "btnMoveKot"; + this.btnMoveKot.Size = new System.Drawing.Size(75, 75); + this.btnMoveKot.TabIndex = 160; + this.btnMoveKot.Text = "Move Kot"; + this.btnMoveKot.UseVisualStyleBackColor = true; + this.btnMoveKot.Click += new System.EventHandler(this.btnMoveKot_Click); + // // label1 // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -547,22 +586,6 @@ this.btnCustomer.UseVisualStyleBackColor = true; this.btnCustomer.Click += new System.EventHandler(this.btnCustomer_Click); // - // printedDataGridViewTextBoxColumn - // - this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; - this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity"; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; - dataGridViewCellStyle4.Format = "N2"; - this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4; - this.printedDataGridViewTextBoxColumn.HeaderText = "Printed"; - this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn"; - this.printedDataGridViewTextBoxColumn.ReadOnly = true; - this.printedDataGridViewTextBoxColumn.Width = 65; - // - // bindingSource - // - this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.BillInventory); - // // bsWaiter // this.bsWaiter.DataSource = typeof(Tanshu.Accounts.Entities.Waiter); @@ -571,26 +594,6 @@ // this.bsPending.DataSource = typeof(Tanshu.Accounts.Contracts.PendingBills); // - // btnMore - // - this.btnMore.Location = new System.Drawing.Point(3, 84); - this.btnMore.Name = "btnMore"; - this.btnMore.Size = new System.Drawing.Size(75, 75); - this.btnMore.TabIndex = 159; - this.btnMore.Text = "More"; - this.btnMore.UseVisualStyleBackColor = true; - this.btnMore.Click += new System.EventHandler(this.btnMore_Click); - // - // btnMoveKot - // - this.btnMoveKot.Location = new System.Drawing.Point(84, 84); - this.btnMoveKot.Name = "btnMoveKot"; - this.btnMoveKot.Size = new System.Drawing.Size(75, 75); - this.btnMoveKot.TabIndex = 160; - this.btnMoveKot.Text = "Move Kot"; - this.btnMoveKot.UseVisualStyleBackColor = true; - this.btnMoveKot.Click += new System.EventHandler(this.btnMoveKot_Click); - // // SalesForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -606,10 +609,10 @@ this.Load += new System.EventHandler(this.SalesForm_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SalesForm_KeyDown); ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); this.pnlBilling.ResumeLayout(false); this.pnlBilling.PerformLayout(); this.flpActions.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bsWaiter)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bsPending)).EndInit(); this.ResumeLayout(false); diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs index 749a3b8..24c52d6 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs @@ -13,11 +13,21 @@ namespace Tanshu.Accounts.PointOfSale.Sales { public partial class SalesForm : Form, ISaleForm { + private readonly IDictionary> productDictionary; + private readonly IList _productGroupList; + private ProductGroup _currentProductGroup; public SalesForm(BillController billController) { InitializeComponent(); + productDictionary = new Dictionary>(); + this._billController = billController; billController.InitGui(this); + using (var bi = new ProductGroupBI()) + _productGroupList = bi.List(); + using (var bi = new ProductBI()) + foreach (var item in _productGroupList) + productDictionary.Add(item.ProductGroupID, bi.List(x => x.ProductGroup.ProductGroupID == item.ProductGroupID)); } #region ISaleForm Members @@ -85,12 +95,12 @@ namespace Tanshu.Accounts.PointOfSale.Sales } case Keys.F7: { - using (var selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true)) - { - selectProduct.ShowDialog(); - if (selectProduct.SelectedItem != null) - _billController.AddProductToGrid(selectProduct.SelectedItem.ProductID); - } + //using (var selectProduct = new SelectProduct(ProductBI.GetFilteredProducts, true)) + //{ + // selectProduct.ShowDialog(); + // if (selectProduct.SelectedItem != null) + // _billController.AddProductToGrid(selectProduct.SelectedItem.ProductID); + //} break; } case Keys.F8: @@ -179,7 +189,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { var dgv = sender as DataGridView; - var data = dgv.Rows[e.RowIndex].DataBoundItem as BillInventory; + var data = dgv.Rows[e.RowIndex].DataBoundItem as BillItemValue; if (data.Tax == -1) { @@ -248,10 +258,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales private void btnModifier_Click(object sender, EventArgs e) { - BillInventory item = _billController.CurrentProduct; + var item = _billController.CurrentProduct; if (item == null) return; - int id = new ProductGroupBI().GetProductGroupOfProduct(item.ProductID).ProductGroupID; + + int id; + using (var bi = new ProductGroupBI()) + id = bi.GetProductGroupOfProduct(item.ProductID).ProductGroupID; _billController.ShowModifiers(id, item); } @@ -296,7 +309,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales #region Helper Functions - public void ClearBill(OrderedDictionary bill) + public void ClearBill(OrderedDictionary bill) { txtBillID.Text = ""; txtKotID.Text = ""; @@ -317,7 +330,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales } public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, - decimal taxAmount, decimal valueAmount, List bill) + decimal taxAmount, decimal valueAmount, List bill) { txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount); txtDiscount.Text = string.Format("{0:#0.00}", discountAmount); @@ -333,15 +346,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales flpGroup.Controls.Clear(); flpMain.Controls.Clear(); if (state == SaleFormState.Billing) - { - IList list = new ProductGroupBI().GetProductGroups(); - ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, list, productTypeButton_Click); - } + ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), 0, _productGroupList, productTypeButton_Click); else - { - ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, new FoodTableBI().List(), - tableButton_Click); - } + using (var bi = new FoodTableBI()) + ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), 0, bi.List(), tableButton_Click); } private void productTypeButton_Click(object sender, EventArgs e) @@ -355,13 +363,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales int start = item.ProductGroupID; if (start < 0) start = 0; - IList list = new ProductGroupBI().GetProductGroups(); - ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, list, productTypeButton_Click); + ControlFactory.GenerateGroups(ref flpGroup, new Point(75, 75), start, _productGroupList, productTypeButton_Click); } else { + _currentProductGroup = item; ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), 0, - ProductBI.GetProducts(item.ProductGroupID), productButton_Click); + productDictionary[item.ProductGroupID], productButton_Click); } } @@ -376,12 +384,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales int start = item.ProductID; if (start < 0) start = 0; - IList list = ProductBI.GetProducts(); - ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, list, productButton_Click); + ControlFactory.GenerateProducts(ref flpMain, new Point(75, 75), start, productDictionary[_currentProductGroup.ProductGroupID], productButton_Click); } else { - _billController.AddProductToGrid(item.ProductID); + _billController.AddProductToGrid(item); } } @@ -393,11 +400,12 @@ namespace Tanshu.Accounts.PointOfSale.Sales var item = button.Tag as FoodTable; if (item.Name == "Previous" || item.Name == "Next") { - int start = item.FoodTableID; + var start = item.FoodTableID; if (start < 0) start = 0; - IList list = new FoodTableBI().List(); - ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, list, tableButton_Click); + + using (var bi = new FoodTableBI()) + ControlFactory.GenerateTables(ref flpMain, new Point(75, 75), start, bi.List(), tableButton_Click); } else { @@ -412,14 +420,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales { if (btnWaiter.Tag == null) btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID; - _billController.Save(true, (int) btnWaiter.Tag, txtTableID.Text); + _billController.SaveBill((int)btnWaiter.Tag, txtTableID.Text); + } private void btnPrintKot_Click(object sender, EventArgs e) { if (btnWaiter.Tag == null) btnWaiter.Tag = WaiterBI.GetWaiters()[0].WaiterID; - _billController.Save(false, (int) btnWaiter.Tag, txtTableID.Text); + _billController.SaveKot((int)btnWaiter.Tag, txtTableID.Text); } private void btnCancel_Click(object sender, EventArgs e) diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx index 53e72f3..c41ea0d 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.resx @@ -123,12 +123,6 @@ 17, 17 - - True - - - 17, 17 - 148, 17 diff --git a/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs index 855c1aa..72c6a14 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SettleChoicesForm.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Windows.Forms; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.Contracts; -using System.Linq; +using Tanshu.Common.Helpers; using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale @@ -14,12 +14,10 @@ namespace Tanshu.Accounts.PointOfSale private readonly IDictionary _list; private decimal _amount; - public SettleChoicesForm(Voucher voucher) + public SettleChoicesForm(decimal amount) { InitializeComponent(); - _amount = voucher.Settlements.Single(x => x.Settled == SettleOption.Amount).Amount + - voucher.Settlements.Single(x => x.Settled == SettleOption.RoundOff).Amount; - _amount *= -1; + _amount = amount; OptionsChosen = new Dictionary(); _list = new Dictionary(); } @@ -83,7 +81,7 @@ namespace Tanshu.Accounts.PointOfSale var count = 0; foreach (SettleOption item in Enum.GetValues(typeof(SettleOption))) { - var attribute = (DisplayAttribute)item.GetType().GetField(item.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0]; + var attribute = item.Attribute(); if (!attribute.ShowInChoices) continue; var button = new Button diff --git a/Tanshu.Accounts.PointOfSale/SplashForm.Designer.cs b/Tanshu.Accounts.PointOfSale/SplashForm.Designer.cs new file mode 100644 index 0000000..179552e --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/SplashForm.Designer.cs @@ -0,0 +1,54 @@ + namespace Tanshu.Accounts.PointOfSale +{ + partial class SplashForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // SplashForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(721, 346); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SplashForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Load += new System.EventHandler(this.SplashForm_Load); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.SplashForm_Paint); + this.ResumeLayout(false); + + } + + #endregion + + + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/SplashForm.cs b/Tanshu.Accounts.PointOfSale/SplashForm.cs new file mode 100644 index 0000000..5321ee4 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/SplashForm.cs @@ -0,0 +1,35 @@ +using System; +using System.Drawing; +using System.Reflection; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class SplashForm : Form + { + public SplashForm() + { + InitializeComponent(); + } + private void SplashForm_Paint(object sender, PaintEventArgs e) + { + // For an image added as a project resource in Visual Studio, + // get the resource by name. + // Bitmap backgroundImage = Properties.Resources.mypicture; + // Otherwise, get the image compiled as an embedded resource. + Assembly asm = Assembly.GetExecutingAssembly(); + Bitmap backgroundImage = new Bitmap(asm.GetManifestResourceStream("Splash")); + + e.Graphics.DrawImage(backgroundImage, this.ClientRectangle, + new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height), + GraphicsUnit.Pixel); + } + + private void SplashForm_Load(object sender, EventArgs e) + { + SessionManager.Initialize(); + this.Close(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/SplashForm.resx b/Tanshu.Accounts.PointOfSale/SplashForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/SplashForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj index 3a9da7e..db9680d 100644 --- a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj +++ b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj @@ -125,19 +125,41 @@ CurrencyCounter.cs + + Form + + + ProductListForm.cs + + + Form + + + ProductGroupListForm.cs + + + True + True + Resources.resx + + + Form + + + BillDetailsForm.cs + Form SaleDetail.cs - - + Form - - FrmSettleAmounts.cs + + frmSettleAmounts.cs Form @@ -151,11 +173,11 @@ frmAdjustAdvance.cs - + Form - - frmMoveTable.cs + + MoveTableForm.cs Form @@ -219,17 +241,17 @@ UserForm.cs - + Form - - ProductsForm.cs + + ProductForm.cs - + Form - - ProductTypes.cs + + ProductGroupForm.cs @@ -240,12 +262,28 @@ CurrencyCounter.cs + + ProductListForm.cs + Designer + + + ProductGroupListForm.cs + Designer + + + ResXFileCodeGenerator + Resources.Designer.cs + + + BillDetailsForm.cs + Designer + SaleDetail.cs Designer - - FrmSettleAmounts.cs + + frmSettleAmounts.cs SettleChoicesForm.cs @@ -254,8 +292,8 @@ frmAdjustAdvance.cs Designer - - frmMoveTable.cs + + MoveTableForm.cs DiscountForm.cs @@ -295,12 +333,12 @@ UserForm.cs Designer - - ProductsForm.cs + + ProductForm.cs Designer - - ProductTypes.cs + + ProductGroupForm.cs Designer @@ -337,6 +375,7 @@ + diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs index da969cf..7ae7551 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs @@ -29,7 +29,8 @@ namespace Tanshu.Accounts.PointOfSale { cmbUsers.DisplayMember = "Name"; cmbUsers.ValueMember = "UserID"; - cmbUsers.DataSource = UserBI.GetUsers(); + using (var bi = new UserBI()) + cmbUsers.DataSource = bi.List(); } private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e) diff --git a/Tanshu.Accounts.PointOfSale/User Management/ChangePassword.cs b/Tanshu.Accounts.PointOfSale/User Management/ChangePassword.cs index 5563cc3..80c09be 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/ChangePassword.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/ChangePassword.cs @@ -65,40 +65,42 @@ namespace Tanshu.Accounts.PointOfSale private bool ChangeUserPassword() { - User userEntity = new User(); + var userEntity = new User(); userEntity.Name = txtUsername.Text.Trim(); userEntity.Password = Tanshu.Common.Md5.Hash(txtPassword.Text.Trim(), "v2"); - if (UserBI.ValidateUser(userEntity.Name, userEntity.Password) != null) - return UserBI.ChangePassword(userEntity, Tanshu.Common.Md5.Hash(txtnewPassword.Text.Trim(), "v2")); - else - return false; + using (var bi = new UserBI()) + if (bi.ValidateUser(userEntity.Name, userEntity.Password) != null) + return bi.ChangePassword(userEntity, Tanshu.Common.Md5.Hash(txtnewPassword.Text.Trim(), "v2")); + else + return false; } private void btnMsr_Click(object sender, EventArgs e) { - User user = new User(); + var user = new User(); user.Name = txtUsername.Text.Trim(); - user.Password = Tanshu.Common.Md5.Hash(txtPassword.Text.Trim(), "v2"); + user.Password = Common.Md5.Hash(txtPassword.Text.Trim(), "v2"); - if (UserBI.ValidateUser(user.Name, user.Password) == null) - return; + using (var bi = new UserBI()) + if (bi.ValidateUser(user.Name, user.Password) == null) + return; using (var frm = new MsrLoginForm(true)) { frm.ShowDialog(); string userName; frm.UserName(out userName); - if (userName != null || userName != string.Empty) + if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != + DialogResult.Yes) + return; + using (var bi = new UserBI()) { - if (MessageBox.Show("Update Msr Card", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - user = UserBI.GetUserFromName(user.Name); - user.MsrString = userName; - UserBI.Update(user); - MessageBox.Show("Msr Card Updated"); - this.Close(); - } + user = bi.Get(x => x.Name == user.Name); + user.MsrString = userName; + bi.Update(user); } + MessageBox.Show("Msr Card Updated"); + this.Close(); } } } diff --git a/Tanshu.Accounts.PointOfSale/User Management/UserForm.Designer.cs b/Tanshu.Accounts.PointOfSale/User Management/UserForm.Designer.cs index 2a5da21..d775aea 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/UserForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/UserForm.Designer.cs @@ -89,7 +89,7 @@ this.btnDelete.TabIndex = 9; this.btnDelete.Text = "&Delete"; this.btnDelete.UseVisualStyleBackColor = true; - this.btnDelete.Click += new System.EventHandler(this.btnCreateUSer_Click); + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); // // btnCancel // diff --git a/Tanshu.Accounts.PointOfSale/User Management/UserForm.cs b/Tanshu.Accounts.PointOfSale/User Management/UserForm.cs index 01d201c..a9e4e53 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/UserForm.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/UserForm.cs @@ -1,26 +1,19 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; -using Tanshu.Accounts.Helpers; using Tanshu.Accounts.Repository; -using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities.Auth; namespace Tanshu.Accounts.PointOfSale { public partial class UserForm : Form { - User user; + User _user; public UserForm(int? userID) { InitializeComponent(); if (userID.HasValue) - user = UserBI.GetUser(userID.Value); + using (var bi = new UserBI()) + _user = bi.Get(x => x.UserID == userID.Value); } private void btnCancel_Click(object sender, EventArgs e) @@ -28,33 +21,36 @@ namespace Tanshu.Accounts.PointOfSale this.Close(); } - private void btnCreateUSer_Click(object sender, EventArgs e) + private void btnDelete_Click(object sender, EventArgs e) { - UserBI.Delete(user.UserID); + using (var bi = new UserBI()) + bi.Delete(x => x.UserID == _user.UserID); btnCancel_Click(sender, e); } private void NewUser_Load(object sender, EventArgs e) { - if (user != null) - { - txtUsername.Text = user.Name; - txtPassword.Text = user.Password; - chkLocked.Checked = user.LockedOut; - } + if (_user == null) + return; + txtUsername.Text = _user.Name; + txtPassword.Text = _user.Password; + chkLocked.Checked = _user.LockedOut; } private bool Save() { - if (user == null) - user = new User(); - user.Name = txtUsername.Text.Trim(); - user.Password = Tanshu.Common.Md5.Hash(txtPassword.Text.Trim(), "v2"); - user.LockedOut = (chkLocked.Checked == true ? true : false); - if (user.UserID == 0) - UserBI.Insert(user); + if (_user == null) + _user = new User(); + _user.Name = txtUsername.Text.Trim(); + if (_user.Password != txtPassword.Text.Trim()) + _user.Password = Common.Md5.Hash(txtPassword.Text.Trim(), "v2"); + _user.LockedOut = (chkLocked.Checked == true ? true : false); + if (_user.UserID == 0) + using (var bi = new UserBI()) + bi.Insert(_user); else - UserBI.Update(user); + using (var bi = new UserBI()) + bi.Update(_user); return true; } diff --git a/Tanshu.Accounts.Print/Thermal.cs b/Tanshu.Accounts.Print/Thermal.cs index 9c4b317..561b3ac 100644 --- a/Tanshu.Accounts.Print/Thermal.cs +++ b/Tanshu.Accounts.Print/Thermal.cs @@ -114,11 +114,35 @@ namespace Tanshu.Accounts.Print if (amount != 0) billText += "\n\r" + FormatText("Service Charge : ", 33, false, Align.Right) + FormatBillNum(amount, 9); - amount = Tax(list.Values); + + // Begin Service Tax and VAT Hack + decimal st = 0; + amount = list.Values.Where(x => x.Tax == 0.14741M).Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax); + st = amount * 0.190564292M; + amount = amount * (1 - 0.190564292M); if (amount != 0) - billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, false, Align.Right) + + billText += "\n\r" + FormatText("VAT @ 12.5% + 5% Sur. : ", 33, false, Align.Right) + FormatBillNum(amount, 9); + amount = list.Values.Where(x => x.Tax == 0.26673M).Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax); + st += amount * 0.105316973M; + amount = amount * (1 - 0.105316973M); + if (amount != 0) + billText += "\n\r" + FormatText("VAT @ 25% + 5% Sur. : ", 33, false, Align.Right) + + FormatBillNum(amount, 9); + + if (st != 0) + billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, false, Align.Right) + + FormatBillNum(st, 9); + //// Original + //amount = Tax(list.Values); + //if (amount != 0) + // billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, false, Align.Right) + + // FormatBillNum(amount, 9); + + // End Service Tax and VAT Hack + + amount = Amount(list.Values); if (amount != 0) billText += string.Format("\n\r Final Amount : {0,9:#,##0.00;(#,##0.00);0}", @@ -341,7 +365,7 @@ namespace Tanshu.Accounts.Print { foreach (var inventory in item.Inventories) { - var type = ProductBI.GetProduct(inventory.Product.ProductID).ProductGroup.ProductGroupID; + var type = inventory.Product.ProductGroup.ProductGroupID; var printer = PrintLocationBI.KotPrinter(type); if (!dict.ContainsKey(printer)) { @@ -351,7 +375,7 @@ namespace Tanshu.Accounts.Print } } stopwatch.Stop(); - Trace.TraceWarning("kot and printers built in {0} ms",stopwatch.ElapsedMilliseconds); + Trace.TraceWarning("kot and printers built in {0} ms", stopwatch.ElapsedMilliseconds); stopwatch.Reset(); foreach (var item in dict) { diff --git a/Tanshu.Accounts.Repository/BusinessLayer/CheckoutBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/CheckoutBI.cs index 8dfd1d6..6d8096e 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/CheckoutBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/CheckoutBI.cs @@ -58,16 +58,17 @@ namespace Tanshu.Accounts.Repository { using (var session = SessionManager.Session) { - this.Cashier = UserBI.GetUser(cashier); + using (var bi = new UserBI(session, false)) + this.Cashier = bi.Get(x => x.UserID == cashier); this.StartDate = startDate.Date.AddHours(6); this.FinishDate = finishDate.Date.AddDays(1).AddHours(5); string info; - PendingBills = GetPrintInfo(out info,SettleOption.Unsettled); + PendingBills = GetPrintInfo(out info, SettleOption.Unsettled); PendingString = info; - CcReceipts = GetPrintInfo(out info,SettleOption.CreditCard); + CcReceipts = GetPrintInfo(out info, SettleOption.CreditCard); CcString = info; - NcReceipts = GetPrintInfo(out info, SettleOption.CreditCard); + NcReceipts = GetPrintInfo(out info, SettleOption.NoCharge); NcString = info; BtcReceipts = GetPrintInfo(out info, SettleOption.BillToCompany); BtcString = info; @@ -143,7 +144,7 @@ namespace Tanshu.Accounts.Repository Voucher voucher = null; decimal amount; decimal discount; - info = string.Format("\n\r--- {0} ", settleOption.Display()).PadRight(44,'-'); + info = string.Format("\n\r--- {0} ", settleOption.Display()).PadRight(44, '-'); var list = session.QueryOver(() => voucher) .Where(i => i.LastEditDate >= StartDate && i.LastEditDate <= FinishDate && @@ -151,7 +152,7 @@ namespace Tanshu.Accounts.Repository i.Void == false) .WithSubquery.WhereExists(QueryOver.Of().Where(x => x.Voucher.VoucherID == voucher.VoucherID && x.Settled == settleOption).Select(x => x.Voucher)) .List(); - GetInfo(list, SettleOption.Unsettled, out amount, out discount, ref info); + GetInfo(list, settleOption, out amount, out discount, ref info); return amount; } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/FluentBaseBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/FluentBaseBI.cs new file mode 100644 index 0000000..9ab77d5 --- /dev/null +++ b/Tanshu.Accounts.Repository/BusinessLayer/FluentBaseBI.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using NHibernate; + +namespace Tanshu.Accounts.Repository +{ + public class FluentBase : IDisposable, IRepository where T : class + { + protected readonly bool DisposeSession; + protected readonly ISession Session; + protected readonly ITransaction Transaction; + + public FluentBase() + { + Session = SessionManager.Session; + DisposeSession = true; + Transaction = Session.BeginTransaction(); + + } + public FluentBase(bool beginTransaction) + { + Session = SessionManager.Session; + DisposeSession = true; + if (beginTransaction) + Transaction = Session.BeginTransaction(); + } + public FluentBase(ISession session) + { + this.Session = session; + DisposeSession = false; + } + public FluentBase(ISession session, bool beginTransaction) + { + this.Session = session; + DisposeSession = false; + if (beginTransaction) + Transaction = Session.BeginTransaction(); + } + + #region IDisposable Members + public void Dispose() + { + if (Transaction != null) + { + Transaction.Commit(); + Transaction.Dispose(); + } + if (DisposeSession && Session != null) + Session.Dispose(); + } + //public void Dispose() + //{ + // Dispose(true); + // GC.SuppressFinalize(this); + //} + + //protected virtual void Dispose(bool disposing) + //{ + // if (Transaction != null) + // { + // Transaction.Commit(); + // Transaction.Dispose(); + // } + // if (DisposeSession && Session != null) + // Session.Dispose(); + + // if (disposing) + // { + // // get rid of managed resources + // } + // // get rid of unmanaged resources + //} + //~FluentBase() + //{ + // Dispose(false); + //} + #endregion + + #region IRepository Members + + public void Insert(T item) + { + Session.Save(item); + } + + public void Update(T item) + { + Session.Update(item); + } + + public void Delete(T item) + { + Session.Delete(item); + } + + public void Delete(Expression> query) + { + Delete(Get(query)); + } + + public void DeleteList(Expression> query) + { + foreach (T item in List(query)) + Delete(item); + } + + public T Get(Expression> query) + { + return Session.QueryOver() + .Where(query) + .SingleOrDefault(); + } + + public IList List() + { + return Session.CreateCriteria() + .List(); + } + + public IList List(Expression> query) + { + return Session.QueryOver() + .Where(query) + .List(); + } + + public void DeleteList(IList list) + { + foreach (T item in list) + Delete(item); + } + + #endregion + } +} diff --git a/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs index 5e0acab..00fe73c 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/FoodTableBI.cs @@ -7,133 +7,69 @@ using System.Linq; namespace Tanshu.Accounts.Repository { - public class FoodTableBI : IDisposable + public class FoodTableBI : FluentBase { - private readonly bool _disposeSession; - private readonly ISession _session; - private readonly bool _useTransaction; - public FoodTableBI() - { - _session = SessionManager.Session; - _disposeSession = true; - _useTransaction = false; - } + : base() + { } + + public FoodTableBI(bool beginTransaction) + : base(beginTransaction) + { } public FoodTableBI(ISession session) - { - this._session = session; - _disposeSession = false; - _useTransaction = false; - } + : base(session) + { } - public FoodTableBI(ISession session, bool useTransaction) - { - this._session = session; - _disposeSession = false; - this._useTransaction = useTransaction; - } - - #region IDisposable Members - - public void Dispose() - { - if (_disposeSession) - _session.Dispose(); - } - - #endregion - - public void Insert(FoodTable foodTable) - { - _session.Save(foodTable); - } - - public void Update(FoodTable foodTable) - { - _session.Update(foodTable); - } - - public void Delete(int foodTableID) - { - _session.Delete(new FoodTable {FoodTableID = foodTableID}); - } - - public FoodTable Get(int foodTableID) - { - return _session.Get(foodTableID); - } - - public FoodTable Get(string name) - { - return _session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - } - - public IList List() - { - return _session.CreateCriteria().List(); - } + public FoodTableBI(ISession session, bool beginTransaction) + : base(session, beginTransaction) + { } public void UpdateStatus(string name, int voucherID, string status) { - if (!_useTransaction) - using (var trans = _session.BeginTransaction()) - { - var table = _session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - if (table == null) - return; - table.VoucherID = string.IsNullOrEmpty(status) ? 0 : voucherID; - table.Status = status; - _session.Update(table); - trans.Commit(); - } - else - { - var table = _session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - table.VoucherID = string.IsNullOrEmpty(status) ? 0 : voucherID; - table.Status = status; - _session.Update(table); - } + var table = Get(x => x.Name == name); + table.VoucherID = string.IsNullOrEmpty(status) ? 0 : voucherID; + table.Status = status; + Session.Update(table); } public int Move(string name, FoodTable foodTable) { - using (var trans = _session.BeginTransaction()) - { - var oldTable = _session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - foodTable.Status = oldTable.Status; - foodTable.VoucherID = oldTable.VoucherID; - oldTable.Status = null; - oldTable.VoucherID = 0; - _session.Merge(foodTable); - _session.Update(oldTable); + var oldTable = Get(x => x.Name == name); + foodTable.Status = oldTable.Status; + foodTable.VoucherID = oldTable.VoucherID; + oldTable.Status = null; + oldTable.VoucherID = 0; + Session.Update(foodTable); + Session.Update(oldTable); - var voucher = _session.Get(foodTable.VoucherID); - voucher.TableID = foodTable.Name; - _session.Update(voucher); - trans.Commit(); - return voucher.VoucherID; - } + var voucher = Session.Get(foodTable.VoucherID); + voucher.TableID = foodTable.Name; + Session.Update(voucher); + return voucher.VoucherID; } public void UpdateStatus(Voucher voucher) { - string status; - if (!voucher.Printed) - status = "running"; - else if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false) - status = "printed"; - else - status = null; - UpdateStatus(voucher.TableID, voucher.VoucherID, status); + string status; + if (!voucher.Printed) + status = "running"; + else if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false) + status = "printed"; + else + status = null; + UpdateStatus(voucher.TableID, voucher.VoucherID, status); + } + public void TableSettled(Voucher voucher) + { + if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) != 0 && voucher.Void == false) + return; + var table = Get(x => x.Name == voucher.TableID && x.VoucherID == voucher.VoucherID); + if (table == null) + return; + table.VoucherID = 0; + table.Status = null; + Session.Update(table); } } } \ No newline at end of file diff --git a/Tanshu.Accounts.Repository/BusinessLayer/IRepositoryBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/IRepositoryBI.cs new file mode 100644 index 0000000..032f4c4 --- /dev/null +++ b/Tanshu.Accounts.Repository/BusinessLayer/IRepositoryBI.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace Tanshu.Accounts.Repository +{ + public interface IRepository + { + void Insert(T item); + void Update(T item); + void Delete(T item); + void Delete(Expression> query); + void DeleteList(Expression> query); + void DeleteList(IList list); + + T Get(Expression> query); + + IList List(); + IList List(Expression> query); + } +} diff --git a/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs index 7b83d3d..895db20 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/ModifierBI.cs @@ -1,51 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using Tanshu.Data.DAO; -using Tanshu.Accounts.Contracts; +using NHibernate; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; namespace Tanshu.Accounts.Repository { - public static class ModifierBI + public class ModifierBI : FluentBase { - public static void Insert(Modifier modifier) - { - using (var session = SessionManager.Session) - { - session.Save(modifier); - } - } - public static void Update(Modifier modifier) - { - using (var session = SessionManager.Session) - { - session.Update(modifier); - } - } - public static void Delete(int modifierID) - { - using (var session = SessionManager.Session) - { - session.Delete(new Modifier() { ModifierID = modifierID }); - } - } - public static Modifier GetModifier(int modifierID) - { - using (var session = SessionManager.Session) - { - return session.Get(modifierID); - } - } - public static IList GetModifiers() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria().List(); - } - } + public ModifierBI(ISession session) + : base(session) + { } + public ModifierBI() + : base() + { } + public ModifierBI(bool useTransaction) + : base(useTransaction) + { } + public ModifierBI(ISession session, bool useTransaction) + : base(session, useTransaction) + { } } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/PrintLocationBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/PrintLocationBI.cs index fece330..1db4355 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/PrintLocationBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/PrintLocationBI.cs @@ -1,87 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tanshu.Accounts.Contracts; -using System.Data.SqlClient; -using Tanshu.Data.DAO; -using System.Configuration; +using System.Configuration; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; -using NHibernate.Criterion; namespace Tanshu.Accounts.Repository { - public class PrintLocationBI + public class PrintLocationBI : FluentBase { - public void Insert(PrintLocation printLocation) - { - using (var session = SessionManager.Session) - { - session.Save(printLocation); - } - } - public void Update(PrintLocation printLocation) - { - using (var session = SessionManager.Session) - { - session.Update(printLocation); - } - } - public void Delete(int printLocationID) - { - using (var session = SessionManager.Session) - { - session.Delete(new PrintLocation() { PrintLocationID = printLocationID }); - } - } - public PrintLocation GetPrintLocation(int printLocationID) - { - using (var session = SessionManager.Session) - { - return session.Get(printLocationID); - } - } - public PrintLocation GetPrintLocation(int productGroupID, string location) - { - using (var session = SessionManager.Session) - { - return (from pl in session.QueryOver() - where pl.ProductGroup.ProductGroupID == productGroupID && pl.Location == location - select pl).SingleOrDefault(); - //return session.CreateCriteria() - // .Add(Restrictions.Eq("ProductGroupID", productGroupID)) - // .Add(Restrictions.Eq("Location", location)) - // .UniqueResult(); - } - } - public PrintLocation GetPrintLocation(string location) - { - using (var session = SessionManager.Session) - { - return (from pl in session.QueryOver() - where pl.Location == location && pl.ProductGroup.ProductGroupID == null - select pl).SingleOrDefault(); - //return session.CreateCriteria() - // .Add(Restrictions.IsNull("ProductGroupID")) - // .Add(Restrictions.Eq("Location", location)) - // .UniqueResult(); - } - } public static PrintLocation BasePrinter { get { - string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant(); - return new PrintLocationBI().GetPrintLocation(location); + var location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant(); + using (var bi = new PrintLocationBI()) + return bi.Get(x => x.Location == location && x.ProductGroup == null); } } public static PrintLocation KotPrinter(int productGroupID) { - string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant(); - PrintLocation p = new PrintLocationBI().GetPrintLocation(productGroupID, location); - if (p == null) - p = new PrintLocationBI().GetPrintLocation(location); - return p; + var location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant(); + using (var bi = new PrintLocationBI()) + return bi.Get(x => x.Location == location && x.ProductGroup.ProductGroupID == productGroupID) ?? + bi.Get(x => x.Location == location && x.ProductGroup == null); } } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/ProductBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/ProductBI.cs index b573687..d83f86b 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/ProductBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/ProductBI.cs @@ -1,67 +1,55 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Linq.Expressions; using Tanshu.Accounts.Contracts; -using System.Data.SqlClient; -using Tanshu.Data.DAO; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; -using NHibernate.Criterion; +using NHibernate; namespace Tanshu.Accounts.Repository { - public static class ProductBI + public class ProductBI : FluentBase { - public static void Insert(Product product) - { - using (var session = SessionManager.Session) - { - session.Save(product); - } - } - public static void Update(Product product) - { - using (var session = SessionManager.Session) - { - session.Update(product); - } + public ProductBI() + : base() + { } - } - public static bool Delete(int productID) + public ProductBI(bool beginTransaction) + : base(beginTransaction) + { } + + public ProductBI(ISession session) + : base(session) + { } + + public ProductBI(ISession session, bool beginTransaction) + : base(session, beginTransaction) + { } + + + public Product Get(string nameAndUnits) { - using (var session = SessionManager.Session) + return Get(x => x.Name + " (" + x.Units + ")" == nameAndUnits); + } + public new IList List(Expression> query) + { + var list = base.List(query); + foreach (var item in list) { - session.Delete(new Product() { ProductID = productID }); - return true; + NHibernateUtil.Initialize(item.ProductGroup); + NHibernateUtil.Initialize(item.Tax); } + return list; } - public static Product GetProductFromName(string nameAndUnits) + + public new IList List() { - using (var session = SessionManager.Session) + var list = base.List(); + foreach (var item in list) { - return session.CreateCriteria() - .Add(Expression.Eq("Name + ' (' + Units + ')'", nameAndUnits)) - .UniqueResult(); - } - } - public static Product GetProduct(int productID) - { - using (var sessioin = SessionManager.Session) - { - return sessioin.Get(productID); - } - } - public static decimal GetProductStock(DateTime date, int productID, int? voucherID) - { - throw new NotImplementedException(); - } - public static IList GetProducts() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .List(); + NHibernateUtil.Initialize(item.ProductGroup); + NHibernateUtil.Initialize(item.Tax); } + return list; } public static List GetFilteredProducts(Dictionary filter) @@ -76,7 +64,7 @@ namespace Tanshu.Accounts.Repository filter.Add("Type", ""); return GetFilteredProducts(filter); } - public static IList GetProducts(int productGroupID) + public static IList List(int productGroupID) { using (var session = SessionManager.Session) { diff --git a/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs index cafa4b3..1c6142d 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs @@ -1,73 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tanshu.Accounts.Contracts; -using System.Data.SqlClient; -using Tanshu.Data.DAO; +using System.Collections.Generic; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; -using NHibernate.Criterion; using NHibernate; namespace Tanshu.Accounts.Repository { - public class ProductGroupBI + public class ProductGroupBI : FluentBase { - public ProductGroup GetProductGroup(int productGroupID) + public ProductGroupBI() + : base() + { } + + public ProductGroupBI(bool beginTransaction) + : base(beginTransaction) + { } + + public ProductGroupBI(ISession session) + : base(session) + { } + + public ProductGroupBI(ISession session, bool beginTransaction) + : base(session, beginTransaction) + { } + + public new IList List() { - using (var session = SessionManager.Session) - { - return session.Get(productGroupID); - } - } - public ProductGroup GetProductGroupByName(string name) - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - } - } - public void Insert(ProductGroup productGroup) - { - using (var session = SessionManager.Session) - { - session.Save(productGroup); - } - } - public void Update(ProductGroup productGroup) - { - using (var session = SessionManager.Session) - { - session.Update(productGroup); - } - } - public IList GetProductGroups() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .AddOrder(Order.Asc("Name")) - .List(); - } + return Session.QueryOver() + .OrderBy(x => x.Name).Asc + .List(); } public IList GetProductGroupTypes() { - using (var session = SessionManager.Session) - { - string query = @"select distinct(pg.GroupType) from ProductGroup pg order by pg.GroupType"; - var hnq = session.CreateQuery(query); - return hnq.List(); - } + const string query = @"select distinct(pg.GroupType) from ProductGroup pg order by pg.GroupType"; + var hnq = Session.CreateQuery(query); + return hnq.List(); } public ProductGroup GetProductGroupOfProduct(int productID) { using (var session = SessionManager.Session) { var item = (from p in session.QueryOver() - where p.ProductID == productID - select p.ProductGroup).SingleOrDefault(); + where p.ProductID == productID + select p.ProductGroup).SingleOrDefault(); NHibernateUtil.Initialize(item); return item; } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/RoleBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/RoleBI.cs index 21164c0..c1601e7 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/RoleBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/RoleBI.cs @@ -1,33 +1,29 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; namespace Tanshu.Accounts.Repository { public delegate bool AuthenticateUser(out string userName); public class RoleBI : IDisposable { - string roleName; - int userID; - bool isAllowed; + readonly string _roleName; + int _userID; + readonly bool _isAllowed; //bool elevated; //AccountsPrincipal originalUser; //AuthenticateUser authenticateUser; public RoleBI(string roleName, int userID) { - this.roleName = roleName; - this.userID = userID; + this._roleName = roleName; + this._userID = userID; if (userID == 0) - isAllowed = false; + _isAllowed = false; else - isAllowed = MembershipBI.IsUserInRole(userID, this.roleName); + _isAllowed = MembershipBI.IsUserInRole(userID, this._roleName); disposed = false; } public bool IsAllowed - { get { return isAllowed; } } + { get { return _isAllowed; } } //public bool IsElevated //{ diff --git a/Tanshu.Accounts.Repository/BusinessLayer/SalesAnalysisBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/SalesAnalysisBI.cs index 7cdb7e8..c3d14f2 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/SalesAnalysisBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/SalesAnalysisBI.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities; using Tanshu.Common; +using Tanshu.Common.Helpers; namespace Tanshu.Accounts.Repository { @@ -110,6 +111,40 @@ order by g.GroupType return GetSettlement(outList, startDate, finishDate); } } + public IList GetBillDetails(DateTime startDate, DateTime finishDate) + { + startDate = startDate.Date.AddHours(6); + finishDate = finishDate.Date.AddDays(1).AddHours(5); + if (finishDate <= startDate) + return new List(); + using (var session = SessionManager.Session) + { + const string query = @" +select v.Date, v.BillID, s.Settled, s.Amount +from Voucher v +inner join v.Settlements s +where v.Date >= :startDate and v.Date <= :finishDate +order by v.BillID, s.Settled +"; + var list = session + .CreateQuery(query) + .SetParameter("startDate", startDate) + .SetParameter("finishDate", finishDate) + .List(); + var outList = new List(); + foreach (var item in list) + { + outList.Add(new BillDetail() + { + Date = (DateTime)item[0], + BillID = (string)item[1], + Settlement = ((SettleOption)item[2]).Display(), + Amount = (decimal)item[3] + }); + } + return outList; + } + } private static IList GetSettlement(IList outList, DateTime startDate, DateTime finishDate) { outList.Add(new SalesAnalysis() { GroupType = " -- ", Amount = 0 }); @@ -135,7 +170,7 @@ order by s.Settled foreach (var item in list) { amount += (decimal)item[1]; - outList.Add(new SalesAnalysis() { GroupType = ((SettleOption)item[0]).ToString(), Amount = (decimal)item[1] }); + outList.Add(new SalesAnalysis() { GroupType = ((SettleOption)item[0]).Display(), Amount = (decimal)item[1] }); } outList.Add(new SalesAnalysis() { GroupType = "Total", Amount = amount }); return GetOtherDetails(outList, startDate, finishDate); diff --git a/Tanshu.Accounts.Repository/BusinessLayer/TaxBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/TaxBI.cs index 5d92879..c7abd26 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/TaxBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/TaxBI.cs @@ -1,60 +1,22 @@ -using System; -using System.Collections.Generic; -//using System.Linq; -using System.Text; -using Tanshu.Accounts.Contracts; -using System.Data.SqlClient; -using Tanshu.Data.DAO; +using NHibernate; using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; -using NHibernate.Criterion; -using Tanshu.Accounts.Entities.Auth; namespace Tanshu.Accounts.Repository { - public static class TaxBI + public class TaxBI : FluentBase { - public static void Insert(Tax tax) - { - using (var session = SessionManager.Session) - { - session.Save(tax); - } - } - public static void Update(Tax tax) - { - using (var session = SessionManager.Session) - { - using (var trans = session.BeginTransaction()) - { - session.Update(tax); - trans.Commit(); - } - } - } - public static void Delete(int taxID) - { - using (var session = SessionManager.Session) - { - session.Delete(new Tax() { TaxID = taxID }); - } - } - - public static Tax GetTax(int taxID) - { - using (var session = SessionManager.Session) - { - return session.Get(taxID); - } - } - public static IList GetTaxes() - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .List(); - } - } + public TaxBI(ISession session) + : base(session) + { } + public TaxBI() + : base() + { } + public TaxBI(bool useTransaction) + : base(useTransaction) + { } + public TaxBI(ISession session, bool useTransaction) + : base(session, useTransaction) + { } } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs index 5609ce0..1ca7313 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/UserBI.cs @@ -1,144 +1,60 @@ using System; using System.Collections.Generic; -//using System.Linq; -using System.Text; -using Tanshu.Accounts.Contracts; -using System.Data.SqlClient; -using Tanshu.Data.DAO; -using Tanshu.Accounts.Entities; -using Tanshu.Accounts.SqlDAO; -using NHibernate.Criterion; +using NHibernate; using Tanshu.Accounts.Entities.Auth; namespace Tanshu.Accounts.Repository { - public static class UserBI + public class UserBI : FluentBase { - public static void Insert(User user) - { - using (var session = SessionManager.Session) - { - session.Save(user); - } - } - public static void Update(User user) - { - using (var session = SessionManager.Session) - { - using (var trans = session.BeginTransaction()) - { - session.Update(user); - trans.Commit(); - } - } - } - public static void Delete(int userID) - { - using (var session = SessionManager.Session) - { - session.Delete(new User() { UserID = userID }); - } - } + public UserBI() + : base() + { } + public UserBI(bool useTransaction) + : base(useTransaction) + { } + public UserBI(ISession session) + : base(session) + { } + public UserBI(ISession session, bool useTransaction) + : base(session, useTransaction) + { } - public static User GetUser(int userID) + public IList GetFilteredUsers(Dictionary filter) { - using (var session = SessionManager.Session) - { - return session.Get(userID); - } + return Session.QueryOver() + .WhereRestrictionOn(x => x.Name).IsLike(string.Format("%{0}%", filter["Name"])) + .List(); } - public static User GetUserFromName(string name) + public bool ChangePassword(User userData, string newPassword) { - using (var session = SessionManager.Session) - { - return (User)session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .UniqueResult(); - } + var dbUser = Get(x => x.Name == userData.Name && x.Password == userData.Password); + if (dbUser == null) + return false; + dbUser.Password = newPassword; + Session.Update(dbUser); + return true; } - - public static IList GetUsers() + public User ValidateUser(string name, string password) { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .List(); - } + return Get(x => x.Name == name && x.Password == password); } - public static IList GetFilteredUsers(Dictionary filter) + public User MsrValidateUser(string msrString) { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .Add(Restrictions.Like("Name", string.Format("%{0}%", filter["Name"]))) - .List(); - } + return Get(x => x.MsrString == msrString); } - public static bool ChangePassword(User userData, string newPassword) + public IList ListActive(DateTime startDate, DateTime finishDate) { - using (var session = SessionManager.Session) - { - using (var trans = session.BeginTransaction()) - { - var dbUser = session.CreateCriteria() - .Add(Restrictions.Eq("Name", userData.Name)) - .Add(Restrictions.Eq("Password", userData.Password)) - .UniqueResult(); - if (dbUser == null) - return false; - dbUser.Password = newPassword; - session.Update(dbUser); - trans.Commit(); - } - return true; - } - } - public static bool Exists(string userName) - { - using (var session = SessionManager.Session) - { - var count = session.CreateCriteria() - .Add(Restrictions.Eq("Name", userName)) - .SetProjection(Projections.Count("UserID")).UniqueResult(); - return (int)count > 0; - } - } - public static User ValidateUser(string name, string password) - { - using (var session = SessionManager.Session) - { - return session.CreateCriteria() - .Add(Restrictions.Eq("Name", name)) - .Add(Restrictions.Eq("Password", password)) - .UniqueResult(); - } - } - public static User MsrValidateUser(string msrString) - { - using (var session = SessionManager.Session) - { - var user = session.CreateCriteria() - .Add(Restrictions.Eq("MsrString", msrString)) - .UniqueResult(); - return user; - } - } - public static IList ListActive(DateTime startDate, DateTime finishDate) - { - using (var session = SessionManager.Session) - { const string query = @" select distinct(u) from Voucher v inner join v.User u where v.Date >= :startDate and v.Date <= :finishDate order by u.Name"; - return session.CreateQuery(query) + return Session.CreateQuery(query) .SetParameter("startDate", startDate) .SetParameter("finishDate", finishDate) .List(); } } - - } } diff --git a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs index 5c18d1b..81bd36d 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using NHibernate.Criterion; using Tanshu.Accounts.Contracts; using Tanshu.Accounts.Entities; using Tanshu.Accounts.Entities.Auth; @@ -10,32 +11,6 @@ namespace Tanshu.Accounts.Repository { public static class VoucherBI { - static public BillInventory GetDefaultSaleBillItem(int productID) - { - Product product; - using (var session = SessionManager.Session) - { - product = session.Get(productID); - return new BillInventory() - { - ProductID = product.ProductID, - Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")", - Price = product.SalePrice, - Tax = product.Tax.Rate, - ServiceCharge = product.ServiceCharge, - Discount = 0, - Printed = false, - Quantity = 1, - }; - } - } - static public decimal GetProductDiscountLimit(int productID) - { - using (var session = SessionManager.Session) - { - return session.Get(productID).ProductGroup.DiscountLimit; - } - } static public bool IsBillPrinted(int voucherID) { using (var session = SessionManager.Session) @@ -43,7 +18,7 @@ namespace Tanshu.Accounts.Repository return session.Get(voucherID).Printed; } } - static public int? Insert(Voucher voucher) + static public int? Insert(Voucher voucher, bool updateTable) { using (var session = SessionManager.Session) { @@ -65,17 +40,18 @@ namespace Tanshu.Accounts.Repository item.User = voucher.User; item.Code = DbValues.KotCode; } - UpdateSettlements(voucher, session); + UpdateSettlements(voucher); session.Save(voucher); - using (var ft = new FoodTableBI(session, true)) - ft.UpdateStatus(voucher); + if (updateTable) + using (var ft = new FoodTableBI(session, false)) + ft.UpdateStatus(voucher); trans.Commit(); return addedKot == null ? (int?)null : addedKot.KotID; } } } - private static void UpdateSettlements(Voucher voucher, ISession session) + private static void UpdateSettlements(Voucher voucher) { var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount)); amount = Math.Round(amount, 5); @@ -92,7 +68,10 @@ namespace Tanshu.Accounts.Repository var balance = voucher.Settlements.Where(x => x.Settled != SettleOption.Unsettled).Sum(x => x.Amount) * -1; if (voucher.Settlements.Count(x => x.Settled == SettleOption.Unsettled) == 0) - voucher.Settlements.Add(new VoucherSettlement() { Amount = balance, Settled = SettleOption.Unsettled }); + { + if (balance != 0) + voucher.Settlements.Add(new VoucherSettlement() { Amount = balance, Settled = SettleOption.Unsettled }); + } else if (balance == 0) voucher.Settlements.Remove(voucher.Settlements.Single(x => x.Settled == SettleOption.Unsettled)); else @@ -105,20 +84,19 @@ namespace Tanshu.Accounts.Repository { using (var trans = session.BeginTransaction()) { - session.Delete(session.Get(voucherID)); - using (var ft = new FoodTableBI(session, true)) + var voucher = session.Get(voucherID); + session.Delete(voucher); + using (var ft = new FoodTableBI(session, false)) { - var table = session.QueryOver() - .Where(x => x.VoucherID == voucherID) - .SingleOrDefault(); - ft.UpdateStatus(table.Name, voucherID, null); + //var table = ft.Get(x=>x.VoucherID == voucherID); + ft.UpdateStatus(voucher.TableID, voucherID, null); } trans.Commit(); } } } - static public int? Update(Voucher voucher) + static public int? Update(Voucher voucher, bool updateTable) { using (var session = SessionManager.Session) { @@ -143,10 +121,11 @@ namespace Tanshu.Accounts.Repository item.User = voucher.User; item.Code = DbValues.KotCode; } - UpdateSettlements(voucher, session); + UpdateSettlements(voucher); session.Update(voucher); - using (var ft = new FoodTableBI(session, true)) - ft.UpdateStatus(voucher); + if (updateTable) + using (var ft = new FoodTableBI(session, false)) + ft.UpdateStatus(voucher); trans.Commit(); if (addedKot == null) return null; @@ -180,10 +159,12 @@ namespace Tanshu.Accounts.Repository foreach (var kot in voucher.Kots) { NHibernateUtil.Initialize(kot); + NHibernateUtil.Initialize(kot.User); foreach (var item in kot.Inventories) { NHibernateUtil.Initialize(item); NHibernateUtil.Initialize(item.Product); + NHibernateUtil.Initialize(item.Product.ProductGroup); foreach (var inmod in item.InventoryModifier) NHibernateUtil.Initialize(inmod.Modifier); } @@ -194,6 +175,17 @@ namespace Tanshu.Accounts.Repository } } + static public Voucher Get(string billID) + { + using (var session = SessionManager.Session) + { + var voucher = session.CreateCriteria() + .Add(Restrictions.Eq("BillID", billID)) + .UniqueResult(); + return voucher != null ? Get(voucher.VoucherID) : null; + } + } + static public void VoidBill(int voucherID, string reason) { using (var session = SessionManager.Session) @@ -218,27 +210,39 @@ namespace Tanshu.Accounts.Repository using (var trans = session.BeginTransaction()) { var voucher = session.Get(voucherID); - foreach (var item in voucher.Settlements.Where(x => x.Settled != SettleOption.Amount && x.Settled != SettleOption.RoundOff && x.Settled != SettleOption.Unsettled)) - session.Delete(item); - foreach (var item in values.Where(x => x.Key != SettleOption.Amount && x.Key != SettleOption.RoundOff && x.Key != SettleOption.Unsettled)) - voucher.Settlements.Add(new VoucherSettlement { Settled = item.Key, Amount = item.Value }); - UpdateSettlements(voucher, session); + + for (var i = voucher.Settlements.Count - 1; i >= 0; i--) + { + var item = voucher.Settlements[i]; + if (item.Settled == SettleOption.Amount || item.Settled == SettleOption.RoundOff || item.Settled == SettleOption.Unsettled) + continue; + if (!values.ContainsKey(item.Settled)) + voucher.Settlements.Remove(item); + else + item.Amount = values[item.Settled]; + + } + foreach (var item in values) + { + if (voucher.Settlements.Count(x => x.Settled == item.Key) == 0) + voucher.Settlements.Add(new VoucherSettlement { Settled = item.Key, Amount = item.Value }); + } + UpdateSettlements(voucher); voucher.User = user; voucher.LastEditDate = DbValues.Date; session.Update(voucher); - using (var ft = new FoodTableBI(session, true)) - ft.UpdateStatus(voucher); + using (var ft = new FoodTableBI(session, false)) + ft.TableSettled(voucher); trans.Commit(); } } } - public static int MoveKot(int kotID, FoodTable foodTable) + public static int MergeKot(int kotID, FoodTable foodTable) { var session = SessionManager.Session; using (var trans = session.BeginTransaction()) { var kot = session.Get(kotID); - foodTable = session.Get(foodTable.FoodTableID); var voucher = session.Get(foodTable.VoucherID); voucher.Kots.Add(kot); session.Update(voucher); @@ -246,6 +250,17 @@ namespace Tanshu.Accounts.Repository return voucher.VoucherID; } } - + public static int MergeKot(int kotID, Voucher voucher) + { + var session = SessionManager.Session; + using (var trans = session.BeginTransaction()) + { + var kot = session.Get(kotID); + voucher.Kots.Add(kot); + session.Update(voucher); + trans.Commit(); + return voucher.VoucherID; + } + } } } diff --git a/Tanshu.Accounts.Repository/DbValuesProgres.cs b/Tanshu.Accounts.Repository/DbValuesProgres.cs new file mode 100644 index 0000000..8c4a768 --- /dev/null +++ b/Tanshu.Accounts.Repository/DbValuesProgres.cs @@ -0,0 +1,63 @@ +using System; + +namespace Tanshu.Accounts.Repository +{ + public static class DbValuesProgres + { + public static DateTime Date + { + get + { + using (var session = SessionManager.Session) + { + var query = session.CreateSQLQuery("SELECT now();"); + return (DateTime)query.UniqueResult(); + } + } + } + public static string KotID + { + get + { + using (var session = SessionManager.Session) + { + const string query = @"SELECT ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 AS nvarchar(8)), 'K-1') FROM Entities_Vouchers"; + var sqlQuery = session.CreateSQLQuery(query); + return (string)sqlQuery.UniqueResult(); + } + } + } + public static string KotCode + { + get + { + using (var session = SessionManager.Session) + { + const string query = @"SELECT ISNULL('S-' + CAST(MAX(CAST(SUBSTRING(Code, 3,8) AS int)) + 1 AS nvarchar(8)), 'S-1') FROM Entities_Kots"; + var sqlQuery = session.CreateSQLQuery(query); + return (string)sqlQuery.UniqueResult(); + } + } + } + public static string BillID + { + get + { + using (var session = SessionManager.Session) + { + const string query = @" + DECLARE @BillID nvarchar(10) + SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM Entities_Vouchers WHERE BillID LIKE '__-____' + IF LEN(@BillID) = 5 + SET @BillID = '0' + @BillID + SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7) + IF SUBSTRING(@BillID,3,7) = '-0000' + SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001' + SELECT @BillID"; + var sqlQuery = session.CreateSQLQuery(query); + return (string)sqlQuery.UniqueResult(); + } + } + } + } +} diff --git a/Tanshu.Accounts.Repository/Fluent/AttributeChecker.cs b/Tanshu.Accounts.Repository/Fluent/AttributeChecker.cs index e9a2e59..f6028b6 100644 --- a/Tanshu.Accounts.Repository/Fluent/AttributeChecker.cs +++ b/Tanshu.Accounts.Repository/Fluent/AttributeChecker.cs @@ -14,6 +14,10 @@ namespace Tanshu.Accounts.SqlDAO { return provider.GetCustomAttributes(typeof(CascadeAttribute), false).Length == 1; } + public static bool Inverse(ICustomAttributeProvider provider) + { + return provider.GetCustomAttributes(typeof(InverseAttribute), false).Length == 1; + } public static bool Unique(ICustomAttributeProvider provider) { return provider.GetCustomAttributes(typeof(UniqueAttribute), false).Length == 1; diff --git a/Tanshu.Accounts.Repository/Fluent/InverseConvention.cs b/Tanshu.Accounts.Repository/Fluent/InverseConvention.cs new file mode 100644 index 0000000..585dc27 --- /dev/null +++ b/Tanshu.Accounts.Repository/Fluent/InverseConvention.cs @@ -0,0 +1,19 @@ +using FluentNHibernate.Conventions; +using FluentNHibernate.Conventions.Instances; +using System.Diagnostics; + +namespace Tanshu.Accounts.SqlDAO +{ + public class InverseConvention : IHasManyConvention //, IReferenceConvention + { + public void Apply(IOneToManyCollectionInstance instance) + { + var property = instance.Member; + if (!AttributeChecker.Inverse(property)) return; + Trace.TraceInformation("Inverse on {0}.{1}", property.DeclaringType.Name, property.Name); + instance.Inverse(); + } + } +} + + diff --git a/Tanshu.Accounts.Repository/Fluent/QueryStore.cs b/Tanshu.Accounts.Repository/Fluent/QueryStore.cs index caa2cb2..7bc976c 100644 --- a/Tanshu.Accounts.Repository/Fluent/QueryStore.cs +++ b/Tanshu.Accounts.Repository/Fluent/QueryStore.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using FluentNHibernate.Conventions; -using FluentNHibernate.Conventions.Instances; -using NHibernate; +using NHibernate; using NHibernate.SqlCommand; using System.Diagnostics; diff --git a/Tanshu.Accounts.Repository/Fluent/SetupStore.cs b/Tanshu.Accounts.Repository/Fluent/SetupStore.cs index 49b4e5e..81d4b6f 100644 --- a/Tanshu.Accounts.Repository/Fluent/SetupStore.cs +++ b/Tanshu.Accounts.Repository/Fluent/SetupStore.cs @@ -19,10 +19,10 @@ namespace Tanshu.Accounts.Repository factory = cfg.BuildSessionFactory(); } - //public static SessionManager Instance - //{ - // get { return Nested.sessionManager; } - //} + public static void Initialize() + { + Nested.sessionManager.Init(); + } public static ISession Session { get { return Nested.sessionManager.GetSession(); } @@ -58,6 +58,7 @@ namespace Tanshu.Accounts.Repository c.Add(); c.Add(); c.Add(); + c.Add(); //c.Add(); c.Add(); }); @@ -68,6 +69,8 @@ namespace Tanshu.Accounts.Repository .BuildConfiguration() .SetInterceptor(new NHSQLInterceptor()); } + private void Init() + { } private ISession GetSession() { return factory.OpenSession(); diff --git a/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj b/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj index c9c10c0..9ad6657 100644 --- a/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj +++ b/Tanshu.Accounts.Repository/Tanshu.Accounts.Repository.csproj @@ -84,10 +84,14 @@ + + + +