public long Insert(DebitMemoItemDetails Details) { try { string SQL = "INSERT INTO tblPODebitMemoItems (" + "DebitMemoID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "PrevUnitCost, " + "UnitCost, " + "Discount, " + "DiscountApplied, " + "DiscountType, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "isVATInclusive, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ItemStatus, " + "IsVatable, " + "Remarks, " + "ChartOfAccountIDPurchase, " + "ChartOfAccountIDTaxPurchase, " + "ChartOfAccountIDInventory" + ") VALUES (" + "@DebitMemoID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@PrevUnitCost, " + "@UnitCost, " + "@Discount, " + "@DiscountApplied, " + "@DiscountType, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@isVATInclusive, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@ItemStatus, " + "@IsVatable, " + "@Remarks, " + "(SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; cmd.Parameters.AddWithValue("@DebitMemoID", Details.DebitMemoID); cmd.Parameters.AddWithValue("@ProductID", Details.ProductID); cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode); cmd.Parameters.AddWithValue("@BarCode", Details.BarCode); cmd.Parameters.AddWithValue("@Description", Details.Description); cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID); cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode); cmd.Parameters.AddWithValue("@Quantity", Details.Quantity); cmd.Parameters.AddWithValue("@PrevUnitCost", Details.PrevUnitCost); cmd.Parameters.AddWithValue("@UnitCost", Details.UnitCost); cmd.Parameters.AddWithValue("@Discount", Details.Discount); cmd.Parameters.AddWithValue("@DiscountApplied", Details.DiscountApplied); cmd.Parameters.AddWithValue("@DiscountType", (int)Details.DiscountType); cmd.Parameters.AddWithValue("@Amount", Details.Amount); cmd.Parameters.AddWithValue("@VAT", Details.VAT); cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); cmd.Parameters.AddWithValue("@EVAT", Details.EVAT); cmd.Parameters.AddWithValue("@EVatableAmount", Details.EVatableAmount); cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax); cmd.Parameters.AddWithValue("@isVATInclusive", Convert.ToInt16(Details.isVATInclusive)); cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID); cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription); cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@ItemStatus", Details.ItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } DebitMemos clsDebitMemos = new DebitMemos(base.Connection, base.Transaction); clsDebitMemos.SynchronizeAmount(Details.DebitMemoID); return(iID); } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SaveRecord() { DebitMemoItemDetails clsDetails = new DebitMemoItemDetails(); Products clsProducts = new Products(); ProductDetails clsProductDetails = clsProducts.Details1(Constants.BRANCH_ID_MAIN, Convert.ToInt64(cboProductCode.SelectedItem.Value)); Terminal clsTerminal = new Terminal(clsProducts.Connection, clsProducts.Transaction); TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString()); clsProducts.CommitAndDispose(); clsDetails.DebitMemoID = Convert.ToInt64(lblDebitMemoID.Text); clsDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value); clsDetails.ProductCode = clsProductDetails.ProductCode; clsDetails.BarCode = clsProductDetails.BarCode; clsDetails.Description = clsProductDetails.ProductDesc; clsDetails.ProductUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value); clsDetails.ProductUnitCode = cboProductUnit.SelectedItem.Text; clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text); clsDetails.PrevUnitCost = Convert.ToDecimal(txtPrevPrice.Text); clsDetails.UnitCost = Convert.ToDecimal(txtPrice.Text); clsDetails.Discount = getItemTotalDiscount(); clsDetails.DiscountApplied = Convert.ToDecimal(txtDiscount.Text); if (clsDetails.DiscountApplied == 0) { if (chkInPercent.Checked == true) clsDetails.DiscountType = DiscountTypes.Percentage; else clsDetails.DiscountType = DiscountTypes.FixedValue; } else { clsDetails.DiscountType = DiscountTypes.NotApplicable; } clsDetails.IsVatable = chkIsTaxable.Checked; clsDetails.Amount = ComputeItemAmount(); if (clsDetails.IsVatable) { clsDetails.VatableAmount = clsDetails.Amount; clsDetails.EVatableAmount = clsDetails.Amount; clsDetails.LocalTax = clsDetails.Amount; if (clsTerminalDetails.IsVATInclusive == false) { if (clsDetails.VatableAmount < clsDetails.Discount) clsDetails.VatableAmount = 0; if (clsDetails.EVatableAmount < clsDetails.Discount) clsDetails.EVatableAmount = 0; if (clsDetails.LocalTax < clsDetails.Discount) clsDetails.LocalTax = 0; } else { if (clsDetails.VatableAmount >= clsDetails.Discount) clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.VatableAmount = 0; if (clsDetails.EVatableAmount >= clsDetails.Discount) clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.EVatableAmount = 0; if (clsDetails.LocalTax >= clsDetails.Discount) clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100)); else clsDetails.LocalTax = 0; } clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100); clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100); clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100); } else { clsDetails.VAT = 0; clsDetails.VatableAmount = 0; clsDetails.EVAT = 0; clsDetails.EVatableAmount = 0; clsDetails.LocalTax = 0; } clsDetails.isVATInclusive = clsTerminalDetails.IsVATInclusive; clsDetails.VariationMatrixID = Convert.ToInt64(cboVariation.SelectedItem.Value); if (clsDetails.VariationMatrixID != 0) clsDetails.MatrixDescription = cboVariation.SelectedItem.Text; clsDetails.ProductGroup = clsProductDetails.ProductGroupCode; clsDetails.ProductSubGroup = clsProductDetails.ProductSubGroupCode; clsDetails.Remarks = txtRemarks.Text; DebitMemoItems clsDebitMemoItems = new DebitMemoItems(); if (lblDebitMemoItemID.Text != "0") { clsDetails.DebitMemoItemID = Convert.ToInt64(lblDebitMemoItemID.Text); clsDebitMemoItems.Update(clsDetails); } else clsDebitMemoItems.Insert(clsDetails); DebitMemoDetails clsDebitMemoDetails = new DebitMemoDetails(); clsDebitMemoDetails.DebitMemoID = clsDetails.DebitMemoID; clsDebitMemoDetails.DiscountApplied = Convert.ToDecimal(txtPODebitMemoDiscountApplied.Text); clsDebitMemoDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscountType.SelectedItem.Value); clsDebitMemoDetails.Discount2Applied = Convert.ToDecimal(txtPODebitMemoDiscount2Applied.Text); clsDebitMemoDetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount2Type.SelectedItem.Value); clsDebitMemoDetails.Discount3Applied = Convert.ToDecimal(txtPODebitMemoDiscount3Applied.Text); clsDebitMemoDetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount3Type.SelectedItem.Value); DebitMemos clsDebitMemos = new DebitMemos(clsDebitMemoItems.Connection, clsDebitMemoItems.Transaction); clsDebitMemos.UpdateDiscount(clsDetails.DebitMemoID, clsDebitMemoDetails.DiscountApplied, clsDebitMemoDetails.DiscountType, clsDebitMemoDetails.Discount2Applied, clsDebitMemoDetails.Discount2Type, clsDebitMemoDetails.Discount3Applied, clsDebitMemoDetails.Discount3Type); clsDebitMemoDetails = clsDebitMemos.Details(clsDetails.DebitMemoID); clsDebitMemoItems.CommitAndDispose(); UpdateFooter(clsDebitMemoDetails); }
public DebitMemoItemDetails Details(long DebitMemoItemID) { try { string SQL = SQLSelect() + "WHERE DebitMemoItemID = @DebitMemoItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmDebitMemoItemID = new MySqlParameter("@DebitMemoItemID", MySqlDbType.Int64); prmDebitMemoItemID.Value = DebitMemoItemID; cmd.Parameters.Add(prmDebitMemoItemID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); DebitMemoItemDetails Details = new DebitMemoItemDetails(); while (myReader.Read()) { Details.DebitMemoItemID = DebitMemoItemID; Details.DebitMemoID = myReader.GetInt64("DebitMemoID"); Details.ProductID = myReader.GetInt64("ProductID"); Details.ProductCode = "" + myReader["ProductCode"].ToString(); Details.BarCode = "" + myReader["BarCode"].ToString(); Details.Description = "" + myReader["Description"].ToString(); Details.ProductUnitID = myReader.GetInt16("ProductUnitID"); Details.ProductUnitCode = "" + myReader["ProductUnitCode"].ToString(); Details.Quantity = myReader.GetDecimal("Quantity"); Details.PrevUnitCost = myReader.GetDecimal("PrevUnitCost"); Details.UnitCost = myReader.GetDecimal("UnitCost"); Details.Discount = myReader.GetDecimal("Discount"); Details.DiscountApplied = myReader.GetDecimal("DiscountApplied"); Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType")); Details.Amount = myReader.GetDecimal("Amount"); Details.VAT = myReader.GetDecimal("VAT"); Details.VatableAmount = myReader.GetDecimal("VatableAmount"); Details.EVAT = myReader.GetDecimal("EVAT"); Details.EVatableAmount = myReader.GetDecimal("EVatableAmount"); Details.LocalTax = myReader.GetDecimal("LocalTax"); Details.isVATInclusive = myReader.GetBoolean("isVATInclusive"); Details.VariationMatrixID = myReader.GetInt64("VariationMatrixID"); Details.MatrixDescription = "" + myReader["MatrixDescription"].ToString(); Details.ProductGroup = "" + myReader["ProductGroup"].ToString(); Details.ProductSubGroup = "" + myReader["ProductSubGroup"].ToString(); Details.ItemStatus = (DebitMemoItemStatus)Enum.Parse(typeof(DebitMemoItemStatus), myReader.GetString("ItemStatus")); if (myReader["IsVatable"].ToString() == "1") { Details.IsVatable = true; } Details.Remarks = "" + myReader["Remarks"].ToString(); } myReader.Close(); return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(DebitMemoItemDetails Details) { try { string SQL = "UPDATE tblPODebitMemoItems SET " + "DebitMemoID = @DebitMemoID, "+ "ProductID = @ProductID, "+ "ProductCode = @ProductCode, "+ "BarCode = @BarCode, "+ "Description = @Description, "+ "ProductUnitID = @ProductUnitID, "+ "ProductUnitCode = @ProductUnitCode, "+ "Quantity = @Quantity, "+ "PrevUnitCost = @PrevUnitCost, "+ "UnitCost = @UnitCost, "+ "Discount = @Discount, "+ "DiscountApplied = @DiscountApplied, "+ "DiscountType = @DiscountType, "+ "Amount = @Amount, "+ "VAT = @VAT, "+ "VatableAmount = @VatableAmount, "+ "EVAT = @EVAT, "+ "EVatableAmount = @EVatableAmount, "+ "LocalTax = @LocalTax, "+ "isVATInclusive = @isVATInclusive, "+ "VariationMatrixID = @VariationMatrixID, "+ "MatrixDescription = @MatrixDescription, "+ "ProductGroup = @ProductGroup, "+ "ProductSubGroup = @ProductSubGroup, "+ "ItemStatus = @ItemStatus, "+ "IsVatable = @IsVatable, "+ "Remarks = @Remarks, "+ "ChartOfAccountIDPurchase = (SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDTaxPurchase = (SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDInventory = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " + "WHERE DebitMemoItemID = @DebitMemoItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; cmd.Parameters.AddWithValue("@DebitMemoID", Details.DebitMemoID); cmd.Parameters.AddWithValue("@ProductID", Details.ProductID); cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode); cmd.Parameters.AddWithValue("@BarCode", Details.BarCode); cmd.Parameters.AddWithValue("@Description", Details.Description); cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID); cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode); cmd.Parameters.AddWithValue("@Quantity", Details.Quantity); cmd.Parameters.AddWithValue("@PrevUnitCost", Details.PrevUnitCost); cmd.Parameters.AddWithValue("@UnitCost", Details.UnitCost); cmd.Parameters.AddWithValue("@Discount", Details.Discount); cmd.Parameters.AddWithValue("@DiscountApplied", Details.DiscountApplied); cmd.Parameters.AddWithValue("@DiscountType", (int)Details.DiscountType); cmd.Parameters.AddWithValue("@Amount", Details.Amount); cmd.Parameters.AddWithValue("@VAT", Details.VAT); cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); cmd.Parameters.AddWithValue("@EVAT", Details.EVAT); cmd.Parameters.AddWithValue("@EVatableAmount", Details.EVatableAmount); cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax); cmd.Parameters.AddWithValue("@isVATInclusive", Convert.ToInt16(Details.isVATInclusive)); cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID); cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription); cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@ItemStatus", Details.ItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@DebitMemoItemID", Details.DebitMemoItemID); base.ExecuteNonQuery(cmd); DebitMemos clsDebitMemos = new DebitMemos(base.Connection, base.Transaction); clsDebitMemos.SynchronizeAmount(Details.DebitMemoID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public long Insert(DebitMemoItemDetails Details) { try { string SQL = "INSERT INTO tblPODebitMemoItems (" + "DebitMemoID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "PrevUnitCost, " + "UnitCost, " + "Discount, " + "DiscountApplied, " + "DiscountType, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "isVATInclusive, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ItemStatus, " + "IsVatable, " + "Remarks, " + "ChartOfAccountIDPurchase, " + "ChartOfAccountIDTaxPurchase, " + "ChartOfAccountIDInventory" + ") VALUES (" + "@DebitMemoID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@PrevUnitCost, " + "@UnitCost, " + "@Discount, " + "@DiscountApplied, " + "@DiscountType, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@isVATInclusive, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@ItemStatus, " + "@IsVatable, " + "@Remarks, " + "(SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; cmd.Parameters.AddWithValue("@DebitMemoID", Details.DebitMemoID); cmd.Parameters.AddWithValue("@ProductID", Details.ProductID); cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode); cmd.Parameters.AddWithValue("@BarCode", Details.BarCode); cmd.Parameters.AddWithValue("@Description", Details.Description); cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID); cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode); cmd.Parameters.AddWithValue("@Quantity", Details.Quantity); cmd.Parameters.AddWithValue("@PrevUnitCost", Details.PrevUnitCost); cmd.Parameters.AddWithValue("@UnitCost", Details.UnitCost); cmd.Parameters.AddWithValue("@Discount", Details.Discount); cmd.Parameters.AddWithValue("@DiscountApplied", Details.DiscountApplied); cmd.Parameters.AddWithValue("@DiscountType", (int)Details.DiscountType); cmd.Parameters.AddWithValue("@Amount", Details.Amount); cmd.Parameters.AddWithValue("@VAT", Details.VAT); cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); cmd.Parameters.AddWithValue("@EVAT", Details.EVAT); cmd.Parameters.AddWithValue("@EVatableAmount", Details.EVatableAmount); cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax); cmd.Parameters.AddWithValue("@isVATInclusive", Convert.ToInt16(Details.isVATInclusive)); cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID); cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription); cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@ItemStatus", Details.ItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } DebitMemos clsDebitMemos = new DebitMemos(base.Connection, base.Transaction); clsDebitMemos.SynchronizeAmount(Details.DebitMemoID); return iID; } catch (Exception ex) { throw base.ThrowException(ex); } }
public DebitMemoItemDetails Details(long DebitMemoItemID) { try { string SQL = SQLSelect() + "WHERE DebitMemoItemID = @DebitMemoItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmDebitMemoItemID = new MySqlParameter("@DebitMemoItemID",MySqlDbType.Int64); prmDebitMemoItemID.Value = DebitMemoItemID; cmd.Parameters.Add(prmDebitMemoItemID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); DebitMemoItemDetails Details = new DebitMemoItemDetails(); while (myReader.Read()) { Details.DebitMemoItemID = DebitMemoItemID; Details.DebitMemoID = myReader.GetInt64("DebitMemoID"); Details.ProductID = myReader.GetInt64("ProductID"); Details.ProductCode = "" + myReader["ProductCode"].ToString(); Details.BarCode = "" + myReader["BarCode"].ToString(); Details.Description = "" + myReader["Description"].ToString(); Details.ProductUnitID = myReader.GetInt16("ProductUnitID"); Details.ProductUnitCode = "" + myReader["ProductUnitCode"].ToString(); Details.Quantity = myReader.GetDecimal("Quantity"); Details.PrevUnitCost = myReader.GetDecimal("PrevUnitCost"); Details.UnitCost = myReader.GetDecimal("UnitCost"); Details.Discount = myReader.GetDecimal("Discount"); Details.DiscountApplied = myReader.GetDecimal("DiscountApplied"); Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType")); Details.Amount = myReader.GetDecimal("Amount"); Details.VAT = myReader.GetDecimal("VAT"); Details.VatableAmount = myReader.GetDecimal("VatableAmount"); Details.EVAT = myReader.GetDecimal("EVAT"); Details.EVatableAmount = myReader.GetDecimal("EVatableAmount"); Details.LocalTax = myReader.GetDecimal("LocalTax"); Details.isVATInclusive = myReader.GetBoolean("isVATInclusive"); Details.VariationMatrixID = myReader.GetInt64("VariationMatrixID"); Details.MatrixDescription = "" + myReader["MatrixDescription"].ToString(); Details.ProductGroup = "" + myReader["ProductGroup"].ToString(); Details.ProductSubGroup = "" + myReader["ProductSubGroup"].ToString(); Details.ItemStatus = (DebitMemoItemStatus)Enum.Parse(typeof(DebitMemoItemStatus), myReader.GetString("ItemStatus")); if (myReader["IsVatable"].ToString() == "1") Details.IsVatable = true; Details.Remarks = "" + myReader["Remarks"].ToString(); } myReader.Close(); return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(DebitMemoItemDetails Details) { try { string SQL = "UPDATE tblPODebitMemoItems SET " + "DebitMemoID = @DebitMemoID, " + "ProductID = @ProductID, " + "ProductCode = @ProductCode, " + "BarCode = @BarCode, " + "Description = @Description, " + "ProductUnitID = @ProductUnitID, " + "ProductUnitCode = @ProductUnitCode, " + "Quantity = @Quantity, " + "PrevUnitCost = @PrevUnitCost, " + "UnitCost = @UnitCost, " + "Discount = @Discount, " + "DiscountApplied = @DiscountApplied, " + "DiscountType = @DiscountType, " + "Amount = @Amount, " + "VAT = @VAT, " + "VatableAmount = @VatableAmount, " + "EVAT = @EVAT, " + "EVatableAmount = @EVatableAmount, " + "LocalTax = @LocalTax, " + "isVATInclusive = @isVATInclusive, " + "VariationMatrixID = @VariationMatrixID, " + "MatrixDescription = @MatrixDescription, " + "ProductGroup = @ProductGroup, " + "ProductSubGroup = @ProductSubGroup, " + "ItemStatus = @ItemStatus, " + "IsVatable = @IsVatable, " + "Remarks = @Remarks, " + "ChartOfAccountIDPurchase = (SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDTaxPurchase = (SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDInventory = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " + "WHERE DebitMemoItemID = @DebitMemoItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; cmd.Parameters.AddWithValue("@DebitMemoID", Details.DebitMemoID); cmd.Parameters.AddWithValue("@ProductID", Details.ProductID); cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode); cmd.Parameters.AddWithValue("@BarCode", Details.BarCode); cmd.Parameters.AddWithValue("@Description", Details.Description); cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID); cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode); cmd.Parameters.AddWithValue("@Quantity", Details.Quantity); cmd.Parameters.AddWithValue("@PrevUnitCost", Details.PrevUnitCost); cmd.Parameters.AddWithValue("@UnitCost", Details.UnitCost); cmd.Parameters.AddWithValue("@Discount", Details.Discount); cmd.Parameters.AddWithValue("@DiscountApplied", Details.DiscountApplied); cmd.Parameters.AddWithValue("@DiscountType", (int)Details.DiscountType); cmd.Parameters.AddWithValue("@Amount", Details.Amount); cmd.Parameters.AddWithValue("@VAT", Details.VAT); cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); cmd.Parameters.AddWithValue("@EVAT", Details.EVAT); cmd.Parameters.AddWithValue("@EVatableAmount", Details.EVatableAmount); cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax); cmd.Parameters.AddWithValue("@isVATInclusive", Convert.ToInt16(Details.isVATInclusive)); cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID); cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription); cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@ItemStatus", Details.ItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@DebitMemoItemID", Details.DebitMemoItemID); base.ExecuteNonQuery(cmd); DebitMemos clsDebitMemos = new DebitMemos(base.Connection, base.Transaction); clsDebitMemos.SynchronizeAmount(Details.DebitMemoID); } catch (Exception ex) { throw base.ThrowException(ex); } }