Initial Json commit from 2 years ago
This commit is contained in:
@ -42,26 +42,29 @@
|
||||
// txtName
|
||||
//
|
||||
this.txtName.AccessibleName = "";
|
||||
this.txtName.Location = new System.Drawing.Point(94, 12);
|
||||
this.txtName.Location = new System.Drawing.Point(125, 15);
|
||||
this.txtName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.txtName.Name = "txtName";
|
||||
this.txtName.Size = new System.Drawing.Size(276, 20);
|
||||
this.txtName.Size = new System.Drawing.Size(367, 22);
|
||||
this.txtName.TabIndex = 0;
|
||||
//
|
||||
// Label2
|
||||
//
|
||||
this.Label2.AutoSize = true;
|
||||
this.Label2.Location = new System.Drawing.Point(53, 15);
|
||||
this.Label2.Location = new System.Drawing.Point(71, 18);
|
||||
this.Label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.Label2.Name = "Label2";
|
||||
this.Label2.Size = new System.Drawing.Size(35, 13);
|
||||
this.Label2.Size = new System.Drawing.Size(45, 17);
|
||||
this.Label2.TabIndex = 10;
|
||||
this.Label2.Text = "Name";
|
||||
//
|
||||
// txtPrice
|
||||
//
|
||||
this.txtPrice.AccessibleName = "Phone 1";
|
||||
this.txtPrice.Location = new System.Drawing.Point(94, 64);
|
||||
this.txtPrice.Location = new System.Drawing.Point(125, 79);
|
||||
this.txtPrice.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.txtPrice.Name = "txtPrice";
|
||||
this.txtPrice.Size = new System.Drawing.Size(65, 20);
|
||||
this.txtPrice.Size = new System.Drawing.Size(85, 22);
|
||||
this.txtPrice.TabIndex = 1;
|
||||
this.txtPrice.Text = "0";
|
||||
this.txtPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
@ -69,17 +72,19 @@
|
||||
// Label5
|
||||
//
|
||||
this.Label5.AutoSize = true;
|
||||
this.Label5.Location = new System.Drawing.Point(57, 67);
|
||||
this.Label5.Location = new System.Drawing.Point(76, 82);
|
||||
this.Label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.Label5.Name = "Label5";
|
||||
this.Label5.Size = new System.Drawing.Size(31, 13);
|
||||
this.Label5.Size = new System.Drawing.Size(40, 17);
|
||||
this.Label5.TabIndex = 11;
|
||||
this.Label5.Text = "Price";
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.Location = new System.Drawing.Point(214, 317);
|
||||
this.btnOk.Location = new System.Drawing.Point(285, 390);
|
||||
this.btnOk.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnOk.Size = new System.Drawing.Size(100, 92);
|
||||
this.btnOk.TabIndex = 6;
|
||||
this.btnOk.Text = "&Ok";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
@ -87,9 +92,10 @@
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Location = new System.Drawing.Point(295, 317);
|
||||
this.btnCancel.Location = new System.Drawing.Point(393, 390);
|
||||
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 75);
|
||||
this.btnCancel.Size = new System.Drawing.Size(100, 92);
|
||||
this.btnCancel.TabIndex = 7;
|
||||
this.btnCancel.Text = "&Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
@ -98,9 +104,10 @@
|
||||
// chkShowInBill
|
||||
//
|
||||
this.chkShowInBill.AutoSize = true;
|
||||
this.chkShowInBill.Location = new System.Drawing.Point(94, 38);
|
||||
this.chkShowInBill.Location = new System.Drawing.Point(125, 47);
|
||||
this.chkShowInBill.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.chkShowInBill.Name = "chkShowInBill";
|
||||
this.chkShowInBill.Size = new System.Drawing.Size(81, 17);
|
||||
this.chkShowInBill.Size = new System.Drawing.Size(101, 21);
|
||||
this.chkShowInBill.TabIndex = 4;
|
||||
this.chkShowInBill.Text = "Show In Bill";
|
||||
this.chkShowInBill.UseVisualStyleBackColor = true;
|
||||
@ -108,9 +115,10 @@
|
||||
// chkShowForAll
|
||||
//
|
||||
this.chkShowForAll.AutoSize = true;
|
||||
this.chkShowForAll.Location = new System.Drawing.Point(94, 90);
|
||||
this.chkShowForAll.Location = new System.Drawing.Point(125, 111);
|
||||
this.chkShowForAll.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.chkShowForAll.Name = "chkShowForAll";
|
||||
this.chkShowForAll.Size = new System.Drawing.Size(119, 17);
|
||||
this.chkShowForAll.Size = new System.Drawing.Size(155, 21);
|
||||
this.chkShowForAll.TabIndex = 3;
|
||||
this.chkShowForAll.Text = "Show for All Groups";
|
||||
this.chkShowForAll.UseVisualStyleBackColor = true;
|
||||
@ -119,17 +127,18 @@
|
||||
// clbGroups
|
||||
//
|
||||
this.clbGroups.FormattingEnabled = true;
|
||||
this.clbGroups.Location = new System.Drawing.Point(94, 113);
|
||||
this.clbGroups.Location = new System.Drawing.Point(125, 139);
|
||||
this.clbGroups.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.clbGroups.Name = "clbGroups";
|
||||
this.clbGroups.Size = new System.Drawing.Size(276, 184);
|
||||
this.clbGroups.Size = new System.Drawing.Size(367, 225);
|
||||
this.clbGroups.TabIndex = 20;
|
||||
this.clbGroups.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.clbGroups_Format);
|
||||
//
|
||||
// ModifierEditForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(382, 404);
|
||||
this.ClientSize = new System.Drawing.Size(509, 497);
|
||||
this.Controls.Add(this.clbGroups);
|
||||
this.Controls.Add(this.chkShowInBill);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
@ -139,11 +148,12 @@
|
||||
this.Controls.Add(this.Label5);
|
||||
this.Controls.Add(this.txtName);
|
||||
this.Controls.Add(this.Label2);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ModifierEditForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Product Types";
|
||||
this.Text = "Modifier";
|
||||
this.Load += new System.EventHandler(this.ModifierEditForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -24,41 +24,35 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void ModifierEditForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Modifier modifier;
|
||||
using (var bi = new ModifierBI())
|
||||
var groups = ProductGroupBI.List();
|
||||
clbGroups.DataSource = groups;
|
||||
if (_modifierID.HasValue)
|
||||
{
|
||||
var groups = bi.ProductGroupList();
|
||||
clbGroups.DataSource = groups;
|
||||
if (_modifierID.HasValue)
|
||||
|
||||
modifier = ModifierBI.Get(_modifierID.Value);
|
||||
|
||||
txtName.Text = modifier.Name;
|
||||
chkShowInBill.Checked = modifier.ShowInBill;
|
||||
txtPrice.Text = modifier.Price.ToString();
|
||||
if (modifier.ProductGroupModifiers.Any(x => x.ProductGroup == null))
|
||||
{
|
||||
|
||||
modifier = bi.Get(x => x.ModifierID == _modifierID.Value);
|
||||
|
||||
txtName.Text = modifier.Name;
|
||||
chkShowInBill.Checked = modifier.ShowInBill;
|
||||
txtPrice.Text = modifier.Price.ToString();
|
||||
if (modifier.ProductGroupModifiers.Any(x => x.ProductGroup == null))
|
||||
{
|
||||
chkShowForAll.Checked = true;
|
||||
clbGroups.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
chkShowForAll.Checked = false;
|
||||
}
|
||||
for (int i = 0; i < clbGroups.Items.Count; i++)
|
||||
{
|
||||
var item = (ProductGroup)clbGroups.Items[i];
|
||||
if (item.ProductGroupModifiers.Any(x => x.Modifier == modifier))
|
||||
{
|
||||
clbGroups.SetItemChecked(i, true);
|
||||
}
|
||||
}
|
||||
chkShowForAll.Checked = true;
|
||||
clbGroups.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
txtName.Focus();
|
||||
chkShowForAll.Checked = false;
|
||||
for (int i = 0; i < clbGroups.Items.Count; i++)
|
||||
{
|
||||
var item = (ProductGroup)clbGroups.Items[i];
|
||||
clbGroups.SetItemChecked(i, modifier.ProductGroupModifiers.Any(x => x.ProductGroup.ProductGroupID == item.ProductGroupID));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
txtName.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
@ -68,32 +62,58 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
Modifier modifier;
|
||||
using (var bi = new ModifierBI())
|
||||
decimal price;
|
||||
if (string.IsNullOrEmpty(txtName.Text.Trim()))
|
||||
{
|
||||
if (_modifierID.HasValue)
|
||||
modifier = bi.Get(x => x.ModifierID == _modifierID.Value);
|
||||
else
|
||||
modifier = new Modifier();
|
||||
|
||||
if (string.IsNullOrEmpty(txtName.Text.Trim()))
|
||||
return;
|
||||
modifier.Name = txtName.Text.Trim();
|
||||
decimal price;
|
||||
if (!decimal.TryParse(txtPrice.Text, out price))
|
||||
return;
|
||||
if (price < 0)
|
||||
return;
|
||||
modifier.Price = price;
|
||||
modifier.ShowInBill = chkShowInBill.Checked;
|
||||
if (_modifierID.HasValue)
|
||||
bi.Update(modifier, chkShowForAll.Checked, clbGroups.CheckedItems.OfType<ProductGroup>());
|
||||
else
|
||||
bi.Insert(modifier, chkShowForAll.Checked, clbGroups.CheckedItems.OfType<ProductGroup>());
|
||||
bi.SaveChanges();
|
||||
MessageBox.Show("Name cannot be blank.");
|
||||
txtName.Focus();
|
||||
}
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
else if (!decimal.TryParse(txtPrice.Text, out price) || price < 0)
|
||||
{
|
||||
MessageBox.Show("Price has to be a number >= 0.");
|
||||
txtName.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Save();
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
private void Save()
|
||||
{
|
||||
Modifier modifier;
|
||||
if (_modifierID.HasValue)
|
||||
modifier = ModifierBI.Get(_modifierID.Value);
|
||||
else
|
||||
modifier = new Modifier();
|
||||
|
||||
modifier.Name = txtName.Text.Trim();
|
||||
modifier.Price = decimal.Parse(txtPrice.Text);
|
||||
modifier.ShowInBill = chkShowInBill.Checked;
|
||||
modifier.ProductGroupModifiers = GetProductGroups(modifier);
|
||||
if (_modifierID.HasValue)
|
||||
ModifierBI.Update(modifier);
|
||||
else
|
||||
ModifierBI.Insert(modifier);
|
||||
|
||||
}
|
||||
private List<ProductGroupModifier> GetProductGroups(Modifier modifier)
|
||||
{
|
||||
var list = new List<ProductGroupModifier>();
|
||||
if (chkShowForAll.Checked)
|
||||
{
|
||||
list.Add(new ProductGroupModifier() { ShowAutomatically = false });
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in clbGroups.CheckedItems.OfType<ProductGroup>())
|
||||
{
|
||||
list.Add(new ProductGroupModifier() { ProductGroup = item });
|
||||
}
|
||||
clbGroups.CheckedItems.OfType<ProductGroup>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
private void clbGroups_Format(object sender, ListControlConvertEventArgs e)
|
||||
{
|
||||
|
||||
@ -112,9 +112,9 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -24,15 +24,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
using (var frm = new ModifierEditForm())
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ModifierBI())
|
||||
_list = bi.List();
|
||||
_list = ModifierBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
private void ModifierListForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new ModifierBI())
|
||||
_list = bi.List();
|
||||
_list = ModifierBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -41,8 +39,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var id = ((Modifier)bsList.Current).ModifierID;
|
||||
using (var frm = new ModifierEditForm(id))
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ModifierBI())
|
||||
_list = bi.List();
|
||||
_list = ModifierBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
this.Label7.Name = "Label7";
|
||||
this.Label7.Size = new System.Drawing.Size(36, 13);
|
||||
this.Label7.TabIndex = 20;
|
||||
this.Label7.Text = "Group";
|
||||
this.Label7.Text = "Role";
|
||||
//
|
||||
// bsServiceTax
|
||||
//
|
||||
@ -157,7 +157,7 @@
|
||||
this.btnAddProductGroup.Name = "btnAddProductGroup";
|
||||
this.btnAddProductGroup.Size = new System.Drawing.Size(96, 21);
|
||||
this.btnAddProductGroup.TabIndex = 11;
|
||||
this.btnAddProductGroup.Text = "Add Group";
|
||||
this.btnAddProductGroup.Text = "Add Role";
|
||||
//
|
||||
// cmbProductGroup
|
||||
//
|
||||
|
||||
@ -18,14 +18,11 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void ProductForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
FillCombos();
|
||||
using (var bis = new SettingBI())
|
||||
ShowServiceChargeControls(bis.Get(x => x.Name == "Service Charge Enabled").Details == "yes");
|
||||
ShowServiceChargeControls((bool)SettingBI.Get("Service Charge").Details["Enabled"]);
|
||||
|
||||
if (_productID.HasValue)
|
||||
{
|
||||
Product product;
|
||||
using (var bi = new ProductBI())
|
||||
product = bi.Get(x => x.ProductID == _productID.Value);
|
||||
Product product = ProductBI.Get(_productID.Value);
|
||||
txtName.Text = product.Name;
|
||||
txtUnits.Text = product.Units;
|
||||
txtPrice.Text = product.Price.ToString("#.##");
|
||||
@ -52,13 +49,9 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
private void FillCombos()
|
||||
{
|
||||
using (var bi = new ProductGroupBI())
|
||||
bsProductGroups.DataSource = bi.List();
|
||||
using (var bi = new TaxBI())
|
||||
{
|
||||
bsServiceTax.DataSource = bi.List();
|
||||
bsVat.DataSource = bi.List();
|
||||
}
|
||||
bsProductGroups.DataSource = ProductGroupBI.List();
|
||||
bsServiceTax.DataSource = TaxBI.List();
|
||||
bsVat.DataSource = TaxBI.List();
|
||||
}
|
||||
|
||||
private void btnAddCategory_Click(object sender, EventArgs e)
|
||||
@ -129,23 +122,19 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
product.IsActive = chkIsActive.Checked;
|
||||
product.IsNotAvailable = chkIsNotAvailable.Checked;
|
||||
|
||||
//Group
|
||||
//Role
|
||||
if (cmbProductGroup.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Please choose Product Group");
|
||||
MessageBox.Show("Please choose Product Role");
|
||||
cmbProductGroup.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
product.ProductGroup = (ProductGroup)cmbProductGroup.SelectedItem;
|
||||
|
||||
using (var bi = new ProductBI())
|
||||
{
|
||||
if (_productID.HasValue)
|
||||
bi.Update(product);
|
||||
else
|
||||
bi.Insert(product);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
if (_productID.HasValue)
|
||||
ProductBI.Update(product);
|
||||
else
|
||||
ProductBI.Insert(product);
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(63, 13);
|
||||
this.label3.TabIndex = 12;
|
||||
this.label3.Text = "Group Type";
|
||||
this.label3.Text = "Role Type";
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
|
||||
@ -20,8 +20,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
if (_productGroupID.HasValue)
|
||||
{
|
||||
ProductGroup productGroup;
|
||||
using (var bi = new ProductGroupBI())
|
||||
productGroup = bi.Get(x => x.ProductGroupID == _productGroupID.Value);
|
||||
productGroup = ProductGroupBI.Get(_productGroupID.Value);
|
||||
txtProductGroupID.Text = _productGroupID.Value.ToString();
|
||||
|
||||
txtName.Text = productGroup.Name;
|
||||
@ -47,14 +46,10 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var productGroup = IsFormValid();
|
||||
if (productGroup != null)
|
||||
{
|
||||
using (var bi = new ProductGroupBI())
|
||||
{
|
||||
if (_productGroupID.HasValue)
|
||||
bi.Update(productGroup);
|
||||
else
|
||||
bi.Insert(productGroup);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
if (_productGroupID.HasValue)
|
||||
ProductGroupBI.Update(productGroup);
|
||||
else
|
||||
ProductGroupBI.Insert(productGroup);
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@ -24,15 +24,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
using (var frm = new ProductGroupForm(null))
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ProductGroupBI())
|
||||
_list = bi.List();
|
||||
_list = ProductGroupBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
private void ProductGroupListForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new ProductGroupBI())
|
||||
_list = bi.List();
|
||||
_list = ProductGroupBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -41,8 +39,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var id = ((ProductGroup)bsList.Current).ProductGroupID;
|
||||
using (var frm = new ProductGroupForm(id))
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ProductGroupBI())
|
||||
_list = bi.List();
|
||||
_list = ProductGroupBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -88,13 +85,9 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new ProductGroupBI())
|
||||
{
|
||||
bi.UpdateSortOrder(_list);
|
||||
bi.SaveChanges();
|
||||
_list = bi.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
ProductGroupBI.UpdateSortOrder(_list);
|
||||
_list = ProductGroupBI.List();
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,11 +200,11 @@
|
||||
this.Vat.ReadOnly = true;
|
||||
this.Vat.Width = 48;
|
||||
//
|
||||
// Group
|
||||
// Role
|
||||
//
|
||||
this.Group.DataPropertyName = "ProductGroup";
|
||||
this.Group.HeaderText = "ProductGroup";
|
||||
this.Group.Name = "Group";
|
||||
this.Group.Name = "Role";
|
||||
this.Group.ReadOnly = true;
|
||||
this.Group.Width = 98;
|
||||
//
|
||||
|
||||
@ -19,8 +19,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
using (var frm = new ProductForm(null))
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ProductBI())
|
||||
_list = bi.List();
|
||||
_list = ProductBI.List(null);
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -30,19 +29,18 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
private void ShowGrid()
|
||||
{
|
||||
using (var bi = new ProductBI())
|
||||
switch (chkIsActive.CheckState)
|
||||
{
|
||||
case CheckState.Checked:
|
||||
_list = bi.List(x => x.IsActive == true);
|
||||
break;
|
||||
case CheckState.Unchecked:
|
||||
_list = bi.List(x => x.IsActive == false);
|
||||
break;
|
||||
default:
|
||||
_list = bi.List();
|
||||
break;
|
||||
}
|
||||
switch (chkIsActive.CheckState)
|
||||
{
|
||||
case CheckState.Checked:
|
||||
_list = ProductBI.List(true);
|
||||
break;
|
||||
case CheckState.Unchecked:
|
||||
_list = ProductBI.List(false);
|
||||
break;
|
||||
default:
|
||||
_list = ProductBI.List(null);
|
||||
break;
|
||||
}
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -51,8 +49,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var id = ((Product)bsList.Current).ProductID;
|
||||
using (var frm = new ProductForm(id))
|
||||
frm.ShowDialog();
|
||||
using (var bi = new ProductBI())
|
||||
_list = bi.List();
|
||||
_list = ProductBI.List(null);
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
@ -119,24 +116,20 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new ProductBI())
|
||||
ProductBI.UpdateSortOrder(_list);
|
||||
switch (chkIsActive.CheckState)
|
||||
{
|
||||
bi.UpdateSortOrder(_list);
|
||||
bi.SaveChanges();
|
||||
switch (chkIsActive.CheckState)
|
||||
{
|
||||
case CheckState.Checked:
|
||||
_list = bi.List(x => x.IsActive == true);
|
||||
break;
|
||||
case CheckState.Unchecked:
|
||||
_list = bi.List(x => x.IsActive == false);
|
||||
break;
|
||||
default:
|
||||
_list = bi.List();
|
||||
break;
|
||||
}
|
||||
bsList.DataSource = _list;
|
||||
case CheckState.Checked:
|
||||
_list = ProductBI.List(true);
|
||||
break;
|
||||
case CheckState.Unchecked:
|
||||
_list = ProductBI.List(false);
|
||||
break;
|
||||
default:
|
||||
_list = ProductBI.List(null);
|
||||
break;
|
||||
}
|
||||
bsList.DataSource = _list;
|
||||
}
|
||||
|
||||
private void chkIsActive_CheckStateChanged(object sender, EventArgs e)
|
||||
|
||||
@ -25,8 +25,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
if (_tableID.HasValue)
|
||||
{
|
||||
FoodTable foodTable;
|
||||
using (var bi = new FoodTableBI())
|
||||
foodTable = bi.Get(x => x.FoodTableID == _tableID.Value);
|
||||
foodTable = FoodTableBI.Get(_tableID.Value);
|
||||
|
||||
txtName.Text = foodTable.Name;
|
||||
txtLocation.Text = foodTable.Location;
|
||||
@ -47,30 +46,26 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
if (IsFormValid())
|
||||
{
|
||||
using (var bi = new FoodTableBI())
|
||||
FoodTable foodTable;
|
||||
if (_tableID.HasValue)
|
||||
{
|
||||
FoodTable foodTable;
|
||||
if (_tableID.HasValue)
|
||||
foodTable = FoodTableBI.Get(_tableID.Value);
|
||||
if (foodTable.IsActive && chkIsActive.Checked == false && (foodTable.Status != null || foodTable.VoucherID.HasValue))
|
||||
{
|
||||
foodTable = bi.Get(x => x.FoodTableID == _tableID.Value);
|
||||
if (foodTable.IsActive && chkIsActive.Checked == false && (foodTable.Status != null || foodTable.VoucherID.HasValue))
|
||||
{
|
||||
MessageBox.Show("Cannot deactivate a table with running bill");
|
||||
return;
|
||||
}
|
||||
MessageBox.Show("Cannot deactivate a table with running bill");
|
||||
return;
|
||||
}
|
||||
else
|
||||
foodTable = new FoodTable();
|
||||
foodTable.Name = txtName.Text.Trim();
|
||||
foodTable.IsActive = chkIsActive.Checked;
|
||||
foodTable.Location = txtLocation.Text.Trim();
|
||||
|
||||
if (_tableID.HasValue)
|
||||
bi.Update(foodTable);
|
||||
else
|
||||
bi.Insert(foodTable);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
else
|
||||
foodTable = new FoodTable();
|
||||
foodTable.Name = txtName.Text.Trim();
|
||||
foodTable.IsActive = chkIsActive.Checked;
|
||||
foodTable.Location = txtLocation.Text.Trim();
|
||||
|
||||
if (_tableID.HasValue)
|
||||
FoodTableBI.Update(foodTable);
|
||||
else
|
||||
FoodTableBI.Insert(foodTable);
|
||||
MessageBox.Show("Update / Save Successful");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user