Updated NH, Code Refactoring, made all DB transactions atomic.

Must use the Repositories with Using or else bad things will happen.
This commit is contained in:
unknown
2011-06-30 01:57:07 +05:30
parent d8ecec8bb6
commit 59909a5ee7
56 changed files with 1964 additions and 1227 deletions

View File

@ -48,6 +48,8 @@
this.cmbProductGroup = new System.Windows.Forms.ComboBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtSortOrder = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsTax)).BeginInit();
this.SuspendLayout();
@ -58,7 +60,7 @@
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.TabIndex = 15;
this.Label4.Text = "Sale Price / Tax";
//
// bsProductGroups
@ -68,10 +70,10 @@
// Label7
//
this.Label7.AutoSize = true;
this.Label7.Location = new System.Drawing.Point(30, 120);
this.Label7.Location = new System.Drawing.Point(70, 119);
this.Label7.Name = "Label7";
this.Label7.Size = new System.Drawing.Size(36, 13);
this.Label7.TabIndex = 33;
this.Label7.TabIndex = 17;
this.Label7.Text = "Group";
//
// bsTax
@ -84,7 +86,7 @@
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.TabIndex = 16;
this.label5.Text = "Service Charge";
//
// label3
@ -93,7 +95,7 @@
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.TabIndex = 13;
this.label3.Text = "Product ID / Code";
//
// txtProductID
@ -102,16 +104,15 @@
this.txtProductID.Name = "txtProductID";
this.txtProductID.ReadOnly = true;
this.txtProductID.Size = new System.Drawing.Size(189, 20);
this.txtProductID.TabIndex = 87;
this.txtProductID.TabIndex = 12;
//
// 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.TabIndex = 0;
this.txtCode.WordWrap = false;
//
// Label2
@ -120,7 +121,7 @@
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.TabIndex = 14;
this.Label2.Text = "Name / Units";
//
// txtUnits
@ -129,7 +130,7 @@
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;
this.txtUnits.TabIndex = 2;
//
// txtName
//
@ -137,7 +138,7 @@
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;
this.txtName.TabIndex = 1;
//
// txtSalePrice
//
@ -145,7 +146,7 @@
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.TabIndex = 3;
this.txtSalePrice.Text = "0";
//
// cmbTax
@ -156,7 +157,7 @@
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.TabIndex = 4;
this.cmbTax.ValueMember = "TaxID";
//
// chkDiscontinued
@ -165,7 +166,7 @@
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.TabIndex = 7;
this.chkDiscontinued.Text = "Discontinued";
this.chkDiscontinued.UseVisualStyleBackColor = true;
//
@ -174,8 +175,8 @@
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.Size = new System.Drawing.Size(73, 20);
this.txtServiceCharge.TabIndex = 5;
this.txtServiceCharge.Text = "0";
//
// btnAddProductGroup
@ -183,7 +184,7 @@
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.TabIndex = 9;
this.btnAddProductGroup.Text = "Add Group";
//
// cmbProductGroup
@ -196,7 +197,7 @@
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.TabIndex = 8;
this.cmbProductGroup.ValueMember = "ProductGroupID";
//
// btnCancel
@ -204,7 +205,7 @@
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.TabIndex = 11;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
@ -214,16 +215,36 @@
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.TabIndex = 10;
this.btnOk.Text = "&Ok";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(196, 93);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(26, 13);
this.label1.TabIndex = 18;
this.label1.Text = "Sort";
//
// txtSortOrder
//
this.txtSortOrder.AccessibleName = "";
this.txtSortOrder.Location = new System.Drawing.Point(228, 90);
this.txtSortOrder.Name = "txtSortOrder";
this.txtSortOrder.Size = new System.Drawing.Size(73, 20);
this.txtSortOrder.TabIndex = 6;
this.txtSortOrder.Text = "0";
//
// 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.txtSortOrder);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.btnAddProductGroup);
@ -275,5 +296,7 @@
internal System.Windows.Forms.ComboBox cmbProductGroup;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOk;
internal System.Windows.Forms.Label label1;
internal System.Windows.Forms.TextBox txtSortOrder;
}
}

View File

@ -1,13 +1,7 @@
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
{
@ -37,6 +31,7 @@ namespace Tanshu.Accounts.PointOfSale
txtServiceCharge.Text = product.ServiceCharge.ToString("#.##");
chkDiscontinued.Checked = product.Discontinued;
cmbProductGroup.SelectedValue = product.ProductGroup.ProductGroupID;
txtSortOrder.Text = product.SortOrder.ToString();
}
else
{
@ -78,8 +73,8 @@ namespace Tanshu.Accounts.PointOfSale
if (string.IsNullOrEmpty(txtName.Text.Trim()))
return null;
product.Name = txtName.Text.Trim();
if (string.IsNullOrEmpty(txtUnits.Text.Trim()))
return null;
//if (string.IsNullOrEmpty(txtUnits.Text.Trim()))
// return null;
product.Units = txtUnits.Text.Trim();
decimal salePrice;
@ -102,6 +97,10 @@ namespace Tanshu.Accounts.PointOfSale
product.ServiceCharge = serviceCharge;
product.Discontinued = chkDiscontinued.Checked;
int sortOrder;
if (!int.TryParse(txtSortOrder.Text, out sortOrder))
return null;
product.SortOrder = sortOrder;
//Group
if (cmbProductGroup.SelectedItem == null)

View File

@ -39,6 +39,9 @@
this.label3 = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.chkDiscontinued = new System.Windows.Forms.CheckBox();
this.txtSortOrder = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtName
@ -47,7 +50,7 @@
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;
this.txtName.TabIndex = 0;
//
// txtProductGroupID
//
@ -57,7 +60,7 @@
this.txtProductGroupID.Name = "txtProductGroupID";
this.txtProductGroupID.ReadOnly = true;
this.txtProductGroupID.Size = new System.Drawing.Size(267, 20);
this.txtProductGroupID.TabIndex = 60;
this.txtProductGroupID.TabIndex = 8;
this.txtProductGroupID.Text = "ProductGroupID";
this.txtProductGroupID.WordWrap = false;
//
@ -67,7 +70,7 @@
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.TabIndex = 10;
this.Label2.Text = "Name";
//
// Label1
@ -76,7 +79,7 @@
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.TabIndex = 9;
this.Label1.Text = "ID";
//
// txtDiscountLimit
@ -85,7 +88,7 @@
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.TabIndex = 1;
this.txtDiscountLimit.Text = "0";
this.txtDiscountLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
@ -95,7 +98,7 @@
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.TabIndex = 11;
this.Label5.Text = "Discount Limit";
//
// chkModifierCompulsory
@ -104,7 +107,7 @@
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.TabIndex = 3;
this.chkModifierCompulsory.Text = "Is Modifier Compulsory?";
this.chkModifierCompulsory.UseVisualStyleBackColor = true;
//
@ -114,7 +117,7 @@
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;
this.txtGroupType.TabIndex = 5;
//
// label3
//
@ -122,7 +125,7 @@
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.TabIndex = 12;
this.label3.Text = "Group Type";
//
// btnOk
@ -130,7 +133,7 @@
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.TabIndex = 6;
this.btnOk.Text = "&Ok";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
@ -140,16 +143,45 @@
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.TabIndex = 7;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// chkDiscontinued
//
this.chkDiscontinued.AutoSize = true;
this.chkDiscontinued.Location = new System.Drawing.Point(237, 90);
this.chkDiscontinued.Name = "chkDiscontinued";
this.chkDiscontinued.Size = new System.Drawing.Size(88, 17);
this.chkDiscontinued.TabIndex = 4;
this.chkDiscontinued.Text = "Discontinued";
this.chkDiscontinued.UseVisualStyleBackColor = true;
//
// txtSortOrder
//
this.txtSortOrder.Location = new System.Drawing.Point(261, 64);
this.txtSortOrder.Name = "txtSortOrder";
this.txtSortOrder.Size = new System.Drawing.Size(100, 20);
this.txtSortOrder.TabIndex = 2;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(200, 67);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 13);
this.label4.TabIndex = 13;
this.label4.Text = "Sort Order";
//
// 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.label4);
this.Controls.Add(this.txtSortOrder);
this.Controls.Add(this.chkDiscontinued);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.txtGroupType);
@ -185,5 +217,8 @@
internal System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.CheckBox chkDiscontinued;
private System.Windows.Forms.TextBox txtSortOrder;
internal System.Windows.Forms.Label label4;
}
}

View File

@ -28,6 +28,8 @@ namespace Tanshu.Accounts.PointOfSale
txtDiscountLimit.Text = productGroup.DiscountLimit.ToString();
chkModifierCompulsory.Checked = productGroup.IsModifierCompulsory;
txtGroupType.Text = productGroup.GroupType;
chkDiscontinued.Checked = productGroup.Discontinued;
txtSortOrder.Text = productGroup.SortOrder.ToString();
}
else
{
@ -71,7 +73,12 @@ namespace Tanshu.Accounts.PointOfSale
if (discount < 0 || discount > 1)
return null;
productGroup.DiscountLimit = discount;
int sortOrder;
if (!int.TryParse(txtSortOrder.Text, out sortOrder))
return null;
productGroup.SortOrder = sortOrder;
productGroup.IsModifierCompulsory = chkModifierCompulsory.Checked;
productGroup.Discontinued = chkDiscontinued.Checked;
if (string.IsNullOrEmpty(txtGroupType.Text.Trim()))
return null;
productGroup.GroupType = txtGroupType.Text.Trim();

View File

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = 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();
@ -38,6 +38,7 @@
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.discountLimitDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SortOrder = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dgvProductTypes)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit();
this.SuspendLayout();
@ -88,7 +89,8 @@
this.dgvProductTypes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.nameDataGridViewTextBoxColumn,
this.discountLimitDataGridViewTextBoxColumn,
this.groupTypeDataGridViewTextBoxColumn});
this.groupTypeDataGridViewTextBoxColumn,
this.SortOrder});
this.dgvProductTypes.DataSource = this.bsList;
this.dgvProductTypes.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dgvProductTypes.Location = new System.Drawing.Point(12, 12);
@ -116,9 +118,9 @@
// discountLimitDataGridViewTextBoxColumn
//
this.discountLimitDataGridViewTextBoxColumn.DataPropertyName = "DiscountLimit";
dataGridViewCellStyle2.Format = "P0";
dataGridViewCellStyle2.NullValue = null;
this.discountLimitDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle1.Format = "P0";
dataGridViewCellStyle1.NullValue = null;
this.discountLimitDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
this.discountLimitDataGridViewTextBoxColumn.HeaderText = "Discount";
this.discountLimitDataGridViewTextBoxColumn.Name = "discountLimitDataGridViewTextBoxColumn";
this.discountLimitDataGridViewTextBoxColumn.ReadOnly = true;
@ -132,6 +134,14 @@
this.groupTypeDataGridViewTextBoxColumn.ReadOnly = true;
this.groupTypeDataGridViewTextBoxColumn.Width = 56;
//
// SortOrder
//
this.SortOrder.DataPropertyName = "SortOrder";
this.SortOrder.HeaderText = "SortOrder";
this.SortOrder.Name = "SortOrder";
this.SortOrder.ReadOnly = true;
this.SortOrder.Width = 77;
//
// ProductGroupListForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -163,5 +173,6 @@
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn discountLimitDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn groupTypeDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn SortOrder;
}
}

View File

@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="SortOrder.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bsList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View File

@ -1,10 +1,4 @@
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;