private void LoadItems() { DataClass clsDataClass = new DataClass(); POReturnItems clsPOReturnItems = new POReturnItems(); lstItem.DataSource = clsPOReturnItems.ListAsDataTable(Convert.ToInt64(lblDebitMemoID.Text), SortField: "DebitMemoItemID", SortOrder: SortOption.Ascending).DefaultView; lstItem.DataBind(); clsPOReturnItems.CommitAndDispose(); lstItemFixCssClass(); }
private void AddItemToInventory(long DebitMemoID) { POReturnDetails clsPOReturnDetails = Details(DebitMemoID); ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction); ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details(); POReturnItems clsPOReturnItems = new POReturnItems(base.Connection, base.Transaction); ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction); Products clsProduct = new Products(base.Connection, base.Transaction); ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction); Inventory clsInventory = new Inventory(base.Connection, base.Transaction); //MySqlDataReader myReader = clsPOReturnItems.List(DebitMemoID, "DebitMemoItemID", SortOption.Ascending); System.Data.DataTable dt = clsPOReturnItems.ListAsDataTable(DebitMemoID); foreach (System.Data.DataRow dr in dt.Rows) { long lngProductID = Convert.ToInt64(dr["ProductID"]); // myReader.GetInt64("ProductID"); int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]); // myReader.GetInt16("ProductUnitID"); decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]); // myReader.GetDecimal("Quantity"); decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity); long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]); // myReader.GetInt64("VariationMatrixID"); string strMatrixDescription = dr["MatrixDescription"].ToString(); // "" + myReader["MatrixDescription"].ToString(); string strProductCode = dr["ProductCode"].ToString(); // "" + myReader["ProductCode"].ToString(); string strProductUnitCode = dr["ProductUnitCode"].ToString(); // "" + myReader["ProductUnitCode"].ToString(); decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]); // myReader.GetDecimal("UnitCost"); decimal decItemCost = Convert.ToDecimal(dr["Amount"]); // myReader.GetDecimal("Amount"); decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT"); /******************************************* * Subtract from Inventory * ****************************************/ // clsProduct.SubtractQuantity(ProductID, Quantity); // if (VariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(VariationMatrixID, Quantity);} // July 26, 2011: change the above codes to the following clsProduct.SubtractQuantity(clsPOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_PURCHASE_RETURN), DateTime.Now, clsPOReturnDetails.MemoNo, clsPOReturnDetails.PurchaserName); /******************************************* * Add to Inventory Analysis * ****************************************/ InventoryDetails clsInventoryDetails = new InventoryDetails(); clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom; clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo; clsInventoryDetails.PostingDate = clsPOReturnDetails.PostingDate; clsInventoryDetails.ReferenceNo = clsPOReturnDetails.MemoNo; clsInventoryDetails.ContactID = clsPOReturnDetails.SupplierID; clsInventoryDetails.ContactCode = clsPOReturnDetails.SupplierCode; clsInventoryDetails.ProductID = lngProductID; clsInventoryDetails.ProductCode = strProductCode; clsInventoryDetails.VariationMatrixID = lngVariationMatrixID; clsInventoryDetails.MatrixDescription = strMatrixDescription; clsInventoryDetails.PReturnQuantity = decQuantity; clsInventoryDetails.PReturnCost = decItemCost - decVAT; clsInventoryDetails.PReturnVAT = decItemCost; //Purchase Return with VAT clsInventory.Insert(clsInventoryDetails); } }
private void SetDataSource(ReportDocument Report) { Int64 iID = 0; try { if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["retid"].ToString() != null) { iID = Convert.ToInt64(Request.QueryString["retid"].ToString()); } else { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["retid"].ToString(), Session.SessionID)); } lblReferrer.ToolTip = iID.ToString(); } catch { iID = long.Parse(lblReferrer.ToolTip); } ReportDataset rptds = new ReportDataset(); POReturns clsPOReturns = new POReturns(); System.Data.DataTable dt = clsPOReturns.ListAsDataTable(DebitMemoID: iID); POReturnItems clsPOReturnItems = new POReturnItems(clsPOReturns.Connection, clsPOReturns.Transaction); System.Data.DataTable dtitems = clsPOReturnItems.ListAsDataTable(iID); clsPOReturns.CommitAndDispose(); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drNew = rptds.POReturns.NewRow(); foreach (DataColumn dc in rptds.POReturns.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.POReturns.Rows.Add(drNew); } foreach(System.Data.DataRow dr in dtitems.Rows) { DataRow drNew = rptds.POReturnItems.NewRow(); foreach (DataColumn dc in rptds.POReturnItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.POReturnItems.Rows.Add(drNew); } Report.SetDataSource(rptds); SetParameters(Report); }
private void UpdateAccounts(long DebitMemoID) { try { POReturnDetails clsPOReturnDetails = Details(DebitMemoID); ChartOfAccounts clsChartOfAccount = new ChartOfAccounts(base.Connection, base.Transaction); // update ChartOfAccountIDAPTracking as credit clsChartOfAccount.UpdateCredit(clsPOReturnDetails.ChartOfAccountIDAPTracking, clsPOReturnDetails.SubTotal); // update Deposit & APContra clsChartOfAccount.UpdateDebit(clsPOReturnDetails.ChartOfAccountIDAPContra, clsPOReturnDetails.Discount); // update Freight & APTracking clsChartOfAccount.UpdateDebit(clsPOReturnDetails.ChartOfAccountIDAPTracking, clsPOReturnDetails.Freight); clsChartOfAccount.UpdateCredit(clsPOReturnDetails.ChartOfAccountIDAPFreight, clsPOReturnDetails.Freight); // update Deposit & APTracking clsChartOfAccount.UpdateDebit(clsPOReturnDetails.ChartOfAccountIDAPTracking, clsPOReturnDetails.Deposit); clsChartOfAccount.UpdateCredit(clsPOReturnDetails.ChartOfAccountIDAPVDeposit, clsPOReturnDetails.Deposit); POReturnItems clsPOReturnItems = new POReturnItems(base.Connection, base.Transaction); System.Data.DataTable dt = clsPOReturnItems.ListAsDataTable(DebitMemoID); foreach (System.Data.DataRow dr in dt.Rows) { int iChartOfAccountIDPurchase = Int16.Parse(dr["ChartOfAccountIDPurchase"].ToString()); int iChartOfAccountIDTaxPurchase = Int16.Parse(dr["ChartOfAccountIDTaxPurchase"].ToString()); decimal decVAT = decimal.Parse(dr["VAT"].ToString()); decimal decVATABLEAmount = decimal.Parse(dr["Amount"].ToString()) - decVAT; // update purchase as debit clsChartOfAccount.UpdateCredit(iChartOfAccountIDPurchase, decVATABLEAmount); // update tax as debit clsChartOfAccount.UpdateCredit(iChartOfAccountIDTaxPurchase, decVAT); } } catch (Exception ex) { throw base.ThrowException(ex); } }