private void LoadItems() { SOReturnItems clsSOReturnItems = new SOReturnItems(); lstItem.DataSource = clsSOReturnItems.ListAsDataTable(Convert.ToInt64(lblCreditMemoID.Text)).DefaultView; lstItem.DataBind(); clsSOReturnItems.CommitAndDispose(); }
private void AddItemToInventory(long CreditMemoID) { SOReturnDetails clsSOReturnDetails = Details(CreditMemoID); ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction); ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details(); SOReturnItems clsSOReturnItems = new SOReturnItems(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); System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID); foreach (System.Data.DataRow dr in dt.Rows) { long lngProductID = long.Parse(dr["ProductID"].ToString()); int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString()); decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString()); decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity); long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString()); string strMatrixDescription = "" + dr["MatrixDescription"].ToString(); string strProductCode = "" + dr["ProductCode"].ToString(); decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString()); decimal decItemCost = decimal.Parse(dr["Amount"].ToString()); decimal decVAT = decimal.Parse(dr["VAT"].ToString()); /******************************************* * Add from Inventory * ****************************************/ // clsProduct.AddQuantity(ProductID, Quantity); // if (VariationMatrixID != 0){ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity); } // July 28, 2011: change the above codes to the following clsProduct.AddQuantity(clsSOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_SALES_RETURN), DateTime.Now, clsSOReturnDetails.CNNo, clsSOReturnDetails.SellerName); /******************************************* * Add to Inventory Analysis * ****************************************/ InventoryDetails clsInventoryDetails = new InventoryDetails(); clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom; clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo; clsInventoryDetails.PostingDate = clsSOReturnDetails.PostingDate; clsInventoryDetails.ReferenceNo = clsSOReturnDetails.CNNo; clsInventoryDetails.ContactID = clsSOReturnDetails.CustomerID; clsInventoryDetails.ContactCode = clsSOReturnDetails.CustomerCode; clsInventoryDetails.ProductID = lngProductID; clsInventoryDetails.ProductCode = strProductCode; clsInventoryDetails.VariationMatrixID = lngVariationMatrixID; clsInventoryDetails.MatrixDescription = strMatrixDescription; clsInventoryDetails.SReturnQuantity = decQuantity; clsInventoryDetails.SReturnCost = decItemCost - decVAT; clsInventoryDetails.SReturnVAT = decItemCost; //Purchase Return with VAT clsInventory.Insert(clsInventoryDetails); } //myReader.Close(); }
private void SetDataSource(ReportDocument Report) { long 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(); SOReturns clsSOReturns = new SOReturns(); MySqlDataReader myreader = clsSOReturns.List(iID, "CreditMemoID", SortOption.Ascending); while (myreader.Read()) { DataRow drNew = rptds.SOReturns.NewRow(); foreach (DataColumn dc in rptds.SOReturns.Columns) drNew[dc] = "" + myreader[dc.ColumnName]; rptds.SOReturns.Rows.Add(drNew); } myreader.Close(); SOReturnItems clsSOReturnItems = new SOReturnItems(clsSOReturns.Connection, clsSOReturns.Transaction); System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(iID); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drNew = rptds.SOReturnItems.NewRow(); foreach (DataColumn dc in rptds.SOReturnItems.Columns) drNew[dc] = "" + dr[dc.ColumnName]; rptds.SOReturnItems.Rows.Add(drNew); } clsSOReturns.CommitAndDispose(); Report.SetDataSource(rptds); SetParameters(Report); }
private void UpdateAccounts(long CreditMemoID) { try { SOReturnDetails clsSOReturnDetails = Details(CreditMemoID); ChartOfAccounts clsChartOfAccount = new ChartOfAccounts(base.Connection, base.Transaction); // update ChartOfAccountIDARTracking as credit clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.SubTotal); // update Deposit & APContra clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARContra, clsSOReturnDetails.Discount); // update Freight & APTracking clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.Freight); clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARFreight, clsSOReturnDetails.Freight); // update Deposit & APTracking clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.Deposit); clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARVDeposit, clsSOReturnDetails.Deposit); SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction); System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID); 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); } //myReader.Close(); } catch (Exception ex) { throw base.ThrowException(ex); } }