Fix: Products edit form vat and st were mixed in combobox.

Fix: Removed MinimumLevel and MaximumLevel from products.
This commit is contained in:
Amritanshu
2013-11-30 16:42:08 +05:30
parent c36240398f
commit 82f3b6b3e7
9 changed files with 166 additions and 370 deletions

View File

@ -208,9 +208,19 @@ namespace Tanshu.Accounts.PointOfSale
}
else
{
ProductsForm form = new ProductsForm();
using (SelectProduct selectProduct = new SelectProduct(new ProductBI().GetFilteredProducts, false))
{
selectProduct.productEvent += new ProductEventHandler(selectProduct_productEvent);
selectProduct.ShowDialog();
}
}
}
ProductBO selectProduct_productEvent(object sender, ProductEventArgs e)
{
using (var form = new ProductsForm(e.ProductID))
{
form.ShowDialog();
form.Dispose();
return form.Product;
}
}

View File

@ -31,32 +31,21 @@
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.GroupBox1 = new System.Windows.Forms.GroupBox();
this.btnAddCategory = new System.Windows.Forms.Button();
this.cmbProductGroups = new System.Windows.Forms.ComboBox();
this.bsTypes = new System.Windows.Forms.BindingSource(this.components);
this.bsProductGroups = new System.Windows.Forms.BindingSource(this.components);
this.cmbUnits = new System.Windows.Forms.ComboBox();
this.bsUnits = new System.Windows.Forms.BindingSource(this.components);
this.Label7 = new System.Windows.Forms.Label();
this.Label3 = 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.txtMinimumLevel = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.txtMaximumLevel = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.btnSave = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.chkDiscontinued = new System.Windows.Forms.CheckBox();
this.cmbVat = new System.Windows.Forms.ComboBox();
this.bsVat = new System.Windows.Forms.BindingSource(this.components);
@ -64,9 +53,8 @@
this.cmbServiceTax = new System.Windows.Forms.ComboBox();
this.bsServiceTax = new System.Windows.Forms.BindingSource(this.components);
this.label8 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.bsProducts)).BeginInit();
this.GroupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.bsTypes)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsUnits)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsVat)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).BeginInit();
@ -84,19 +72,12 @@
// txtSalePrice
//
this.txtSalePrice.AccessibleName = "Phone 1";
this.txtSalePrice.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "SalePrice", true));
this.txtSalePrice.Location = new System.Drawing.Point(13, 164);
this.txtSalePrice.Name = "txtSalePrice";
this.txtSalePrice.Size = new System.Drawing.Size(74, 20);
this.txtSalePrice.TabIndex = 53;
this.txtSalePrice.Text = "0";
//
// bsProducts
//
this.bsProducts.DataSource = typeof(Tanshu.Accounts.Contracts.ProductBO);
this.bsProducts.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.bsProducts_AddingNew);
this.bsProducts.PositionChanged += new System.EventHandler(this.bsProducts_PositionChanged);
//
// GroupBox1
//
this.GroupBox1.Controls.Add(this.btnAddCategory);
@ -123,8 +104,7 @@
//
// cmbProductGroups
//
this.cmbProductGroups.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "ProductGroupID", true));
this.cmbProductGroups.DataSource = this.bsTypes;
this.cmbProductGroups.DataSource = this.bsProductGroups;
this.cmbProductGroups.DisplayMember = "Name";
this.cmbProductGroups.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbProductGroups.Location = new System.Drawing.Point(94, 72);
@ -133,13 +113,12 @@
this.cmbProductGroups.TabIndex = 35;
this.cmbProductGroups.ValueMember = "ProductGroupID";
//
// bsTypes
// bsProductGroups
//
this.bsTypes.DataSource = typeof(Tanshu.Accounts.Contracts.ProductGroupBO);
this.bsProductGroups.DataSource = typeof(Tanshu.Accounts.Contracts.ProductGroupBO);
//
// cmbUnits
//
this.cmbUnits.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "Units", true));
this.cmbUnits.DataSource = this.bsUnits;
this.cmbUnits.DisplayMember = "Description";
this.cmbUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@ -174,7 +153,6 @@
// txtName
//
this.txtName.AccessibleName = "";
this.txtName.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "Name", true));
this.txtName.Location = new System.Drawing.Point(94, 19);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(212, 20);
@ -189,58 +167,9 @@
this.Label2.TabIndex = 28;
this.Label2.Text = "Name";
//
// btnNavFirst
//
this.btnNavFirst.Location = new System.Drawing.Point(40, 334);
this.btnNavFirst.Name = "btnNavFirst";
this.btnNavFirst.Size = new System.Drawing.Size(40, 23);
this.btnNavFirst.TabIndex = 44;
this.btnNavFirst.Text = "<<";
this.btnNavFirst.Click += new System.EventHandler(this.btnNavFirst_Click);
//
// btnNavPrev
//
this.btnNavPrev.Location = new System.Drawing.Point(86, 334);
this.btnNavPrev.Name = "btnNavPrev";
this.btnNavPrev.Size = new System.Drawing.Size(35, 23);
this.btnNavPrev.TabIndex = 45;
this.btnNavPrev.Text = "<";
this.btnNavPrev.Click += new System.EventHandler(this.btnNavPrev_Click);
//
// lblNavLocation
//
this.lblNavLocation.BackColor = System.Drawing.Color.White;
this.lblNavLocation.Location = new System.Drawing.Point(118, 334);
this.lblNavLocation.Name = "lblNavLocation";
this.lblNavLocation.Size = new System.Drawing.Size(95, 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.Location = new System.Drawing.Point(214, 334);
this.btnNavNext.Name = "btnNavNext";
this.btnNavNext.Size = new System.Drawing.Size(35, 23);
this.btnNavNext.TabIndex = 47;
this.btnNavNext.Text = ">";
this.btnNavNext.Click += new System.EventHandler(this.btnNavNext_Click);
//
// btnLast
//
this.btnLast.Location = new System.Drawing.Point(254, 334);
this.btnLast.Name = "btnLast";
this.btnLast.Size = new System.Drawing.Size(40, 23);
this.btnLast.TabIndex = 48;
this.btnLast.Text = ">>";
this.btnLast.Click += new System.EventHandler(this.btnLast_Click);
//
// txtUniqueID
//
this.txtUniqueID.AccessibleName = "Unique ID";
this.txtUniqueID.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "Code", true));
this.txtUniqueID.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.bsProducts, "ProductID", true));
this.txtUniqueID.Enabled = false;
this.txtUniqueID.Location = new System.Drawing.Point(75, 12);
this.txtUniqueID.Name = "txtUniqueID";
@ -259,87 +188,39 @@
this.Label1.Text = "Code";
this.Label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(9, 300);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(75, 23);
this.btnAdd.TabIndex = 72;
this.btnAdd.Text = "&Add";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(91, 300);
this.btnDelete.Location = new System.Drawing.Point(90, 214);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(75, 23);
this.btnDelete.TabIndex = 73;
this.btnDelete.Text = "&Delete";
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnUpdate
// btnSave
//
this.btnUpdate.AccessibleName = "Done";
this.btnUpdate.Location = new System.Drawing.Point(173, 300);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(72, 24);
this.btnUpdate.TabIndex = 71;
this.btnUpdate.Text = "&Update";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
this.btnSave.AccessibleName = "Done";
this.btnSave.Location = new System.Drawing.Point(12, 213);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(72, 24);
this.btnSave.TabIndex = 71;
this.btnSave.Text = "&Save";
this.btnSave.Click += new System.EventHandler(this.btnUpdate_Click);
//
// btnExit
// btnCancel
//
this.btnExit.AccessibleName = "Done";
this.btnExit.Location = new System.Drawing.Point(252, 300);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 24);
this.btnExit.TabIndex = 70;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// txtMinimumLevel
//
this.txtMinimumLevel.AccessibleName = "Phone 1";
this.txtMinimumLevel.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "MinimumLevel", true));
this.txtMinimumLevel.Location = new System.Drawing.Point(10, 264);
this.txtMinimumLevel.Name = "txtMinimumLevel";
this.txtMinimumLevel.Size = new System.Drawing.Size(77, 20);
this.txtMinimumLevel.TabIndex = 75;
this.txtMinimumLevel.Text = "0";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(10, 248);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(77, 13);
this.label6.TabIndex = 74;
this.label6.Text = "Minimum Level";
//
// txtMaximumLevel
//
this.txtMaximumLevel.AccessibleName = "Phone 1";
this.txtMaximumLevel.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "MaximumLevel", true));
this.txtMaximumLevel.Location = new System.Drawing.Point(96, 264);
this.txtMaximumLevel.Name = "txtMaximumLevel";
this.txtMaximumLevel.Size = new System.Drawing.Size(85, 20);
this.txtMaximumLevel.TabIndex = 77;
this.txtMaximumLevel.Text = "0";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(93, 249);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(80, 13);
this.label9.TabIndex = 76;
this.label9.Text = "Maximum Level";
this.btnCancel.AccessibleName = "Done";
this.btnCancel.Location = new System.Drawing.Point(255, 214);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(72, 24);
this.btnCancel.TabIndex = 70;
this.btnCancel.Text = "&Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// chkDiscontinued
//
this.chkDiscontinued.AutoSize = true;
this.chkDiscontinued.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.bsProducts, "Discontinued", true));
this.chkDiscontinued.Location = new System.Drawing.Point(233, 272);
this.chkDiscontinued.Location = new System.Drawing.Point(16, 190);
this.chkDiscontinued.Name = "chkDiscontinued";
this.chkDiscontinued.Size = new System.Drawing.Size(88, 17);
this.chkDiscontinued.TabIndex = 78;
@ -348,11 +229,10 @@
//
// cmbVat
//
this.cmbVat.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "VatID", true));
this.cmbVat.DataSource = this.bsVat;
this.cmbVat.DisplayMember = "Name";
this.cmbVat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbVat.Location = new System.Drawing.Point(236, 163);
this.cmbVat.Location = new System.Drawing.Point(106, 163);
this.cmbVat.Name = "cmbVat";
this.cmbVat.Size = new System.Drawing.Size(91, 21);
this.cmbVat.TabIndex = 82;
@ -365,7 +245,7 @@
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(241, 148);
this.label10.Location = new System.Drawing.Point(111, 148);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(23, 13);
this.label10.TabIndex = 81;
@ -373,11 +253,10 @@
//
// cmbServiceTax
//
this.cmbServiceTax.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "VatID", true));
this.cmbServiceTax.DataSource = this.bsServiceTax;
this.cmbServiceTax.DisplayMember = "Name";
this.cmbServiceTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbServiceTax.Location = new System.Drawing.Point(236, 205);
this.cmbServiceTax.Location = new System.Drawing.Point(227, 164);
this.cmbServiceTax.Name = "cmbServiceTax";
this.cmbServiceTax.Size = new System.Drawing.Size(91, 21);
this.cmbServiceTax.TabIndex = 84;
@ -390,7 +269,7 @@
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(241, 190);
this.label8.Location = new System.Drawing.Point(223, 148);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(64, 13);
this.label8.TabIndex = 83;
@ -400,29 +279,19 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(336, 365);
this.ClientSize = new System.Drawing.Size(336, 249);
this.Controls.Add(this.cmbServiceTax);
this.Controls.Add(this.label8);
this.Controls.Add(this.cmbVat);
this.Controls.Add(this.Label1);
this.Controls.Add(this.label10);
this.Controls.Add(this.chkDiscontinued);
this.Controls.Add(this.txtMaximumLevel);
this.Controls.Add(this.label9);
this.Controls.Add(this.txtMinimumLevel);
this.Controls.Add(this.label6);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnUpdate);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.Label4);
this.Controls.Add(this.txtSalePrice);
this.Controls.Add(this.GroupBox1);
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.txtUniqueID);
this.MaximizeBox = false;
this.MinimizeBox = false;
@ -430,10 +299,9 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Products";
this.Load += new System.EventHandler(this.Products_Load);
((System.ComponentModel.ISupportInitialize)(this.bsProducts)).EndInit();
this.GroupBox1.ResumeLayout(false);
this.GroupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.bsTypes)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsUnits)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsVat)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).EndInit();
@ -454,27 +322,16 @@
internal System.Windows.Forms.Label Label3;
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;
internal System.Windows.Forms.TextBox txtMinimumLevel;
internal System.Windows.Forms.Label label6;
internal System.Windows.Forms.TextBox txtMaximumLevel;
internal System.Windows.Forms.Label label9;
internal System.Windows.Forms.Button btnSave;
internal System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.CheckBox chkDiscontinued;
internal System.Windows.Forms.ComboBox cmbVat;
internal System.Windows.Forms.Label label10;
private System.Windows.Forms.BindingSource bsProducts;
private System.Windows.Forms.BindingSource bsUnits;
private System.Windows.Forms.BindingSource bsTypes;
private System.Windows.Forms.BindingSource bsProductGroups;
private System.Windows.Forms.BindingSource bsVat;
private System.Windows.Forms.BindingSource bsServiceTax;
internal System.Windows.Forms.ComboBox cmbServiceTax;

View File

@ -13,111 +13,72 @@ namespace Tanshu.Accounts.PointOfSale
{
bool createOnly = false;
List<ProductDisplayBO> productList = new List<ProductDisplayBO>();
Guid? _productID;
ProductBO product;
#region Form Load
public ProductsForm()
public ProductsForm(Guid? productID)
{
_productID = productID;
InitializeComponent();
}
private void Products_Load(object sender, EventArgs e)
{
productList = new ProductBI().GetProducts();
bsProducts.DataSource = productList;
FillCombos();
bsProducts.MoveFirst();
if (_productID.HasValue)
{
product = new ProductBI().GetProduct(_productID.Value);
txtUniqueID.Text = product.Code.ToString();
txtName.Text = product.Name;
cmbUnits.SelectedItem = product.Units;
cmbProductGroups.SelectedValue = product.ProductGroupID;
txtSalePrice.Text = product.SalePrice.ToString();
cmbVat.SelectedValue = product.VatID;
cmbServiceTax.SelectedValue = product.ServiceTaxID;
chkDiscontinued.Checked = product.Discontinued;
btnSave.Text = "&Update";
btnDelete.Enabled = true;
}
else
{
btnSave.Text = "&Save";
btnDelete.Enabled = false;
}
}
private void FillCombos()
{
bsUnits.DataSource = new StringType[17] {new StringType ( "Cms"),
new StringType ("Meter"),
new StringType ("Quintal"),
new StringType ("Can"),
new StringType ("Gms"),
new StringType ("Rs."),
new StringType ("Piece"),
new StringType ("Petti"),
new StringType ("No.'s"),
new StringType ("Liter"),
new StringType ("Box"),
new StringType ("Tin"),
new StringType ("Dibbi"),
new StringType ("Plate"),
new StringType ("Kg."),
new StringType ("Bottle"),
new StringType ("Pack" )};
bsTypes.DataSource = new ProductBI().GetProductGroups();
string[] units = { "Can", "Gms", "Rs.", "Piece", "Liter", "Plate", "Kg.", "Bottle", "Pack" };
bsUnits.DataSource = units;
bsProductGroups.DataSource = new ProductBI().GetProductGroups();
bsVat.DataSource = new ProductBI().GetTaxes();
bsServiceTax.DataSource = new ProductBI().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 = new 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 (new ProductBI().Delete(productList.Single(p => p.Code == Convert.ToInt32(txtUniqueID.Text)).ProductID))
{
productList = new ProductBI().GetProducts();
btnNavFirst_Click(sender, e);
}
}
}
}
if (MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
else
if (new ProductBI().Delete(product.ProductID))
{
LockControls(false);
bsProducts.CancelEdit();
btnCancel_Click(sender, e);
}
}
private void btnUpdate_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
if (!ValidateValues())
{
Save(false);
bsProducts.ResetItem(bsProducts.Position);
MessageBox.Show("Missing Information: Please check the form.");
txtName.Focus();
}
else if (MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
Save();
btnCancel_Click(sender, e);
}
}
#endregion
@ -132,16 +93,11 @@ namespace Tanshu.Accounts.PointOfSale
return returnType;
}
private bool Save(bool addNew)
private void Save()
{
#region Setup Products
UserBO user = CurrentUser.user;
ProductBO product = new ProductBO();
if (!addNew)
product = new ProductBI().GetProduct(productList.ElementAt(bsProducts.Position).ProductID);
if (product == null)
product = new ProductBO();
product.Name = txtName.Text;
product.MinimumLevel = Convert.ToDecimal(txtMinimumLevel.Text);
product.MaximumLevel = Convert.ToDecimal(txtMaximumLevel.Text);
product.Units = cmbUnits.Text;
product.ProductGroupID = new Guid(cmbProductGroups.SelectedValue.ToString());
product.SalePrice = Convert.ToDecimal(txtSalePrice.Text);
@ -149,100 +105,30 @@ namespace Tanshu.Accounts.PointOfSale
product.ServiceTaxID = new Guid(cmbServiceTax.SelectedValue.ToString());
product.Discontinued = chkDiscontinued.Checked;
product.VatID = new Guid(cmbVat.SelectedValue.ToString());
if (addNew)
if (product.ProductID == new Guid())
new ProductBI().Insert(product);
else
new ProductBI().Update(product);
return true;
#endregion
}
#endregion
private void btnExit_Click(object sender, EventArgs e)
private void btnCancel_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)
{
ProductGroups frm = new ProductGroups();
frm.ShowDialog();
frm.Dispose();
using (var frm = new ProductGroups())
{
frm.ShowDialog();
}
FillCombos();
cmbProductGroups.SelectedIndex = 0;
}
#region Move Buttons
private void btnNavFirst_Click(object sender, EventArgs e)
public ProductBO Product
{
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(new 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 ProductDisplayBO();
}
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(List<ProductDisplayBO> list, Guid id)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].ProductID == id)
return i;
}
return 0;
get { return null; }
}
}
}

View File

@ -117,10 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bsProducts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="bsTypes.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="bsProductGroups.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>251, 17</value>
</metadata>
<metadata name="bsUnits.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">