Esempio n. 1
0
		private void LoadItems()
		{
			DataClass clsDataClass = new DataClass();

			DebitMemoItems clsDebitMemoItems = new DebitMemoItems();
			lstItem.DataSource = clsDebitMemoItems.ListAsDataTable(Convert.ToInt64(lblDebitMemoID.Text)).DefaultView;
			lstItem.DataBind();
			clsDebitMemoItems.CommitAndDispose();
		}
Esempio n. 2
0
        private void UpdateAccounts(long DebitMemoID)
        {
            try
            {
                DebitMemoDetails clsDebitMemoDetails = Details(DebitMemoID);
                ChartOfAccounts clsChartOfAccount = new ChartOfAccounts(base.Connection, base.Transaction);

                // update ChartOfAccountIDAPTracking as credit
                clsChartOfAccount.UpdateCredit(clsDebitMemoDetails.ChartOfAccountIDAPTracking, clsDebitMemoDetails.SubTotal);

                // update Deposit & APContra
                clsChartOfAccount.UpdateCredit(clsDebitMemoDetails.ChartOfAccountIDAPContra, clsDebitMemoDetails.Discount);

                // update Freight & APTracking
                clsChartOfAccount.UpdateDebit(clsDebitMemoDetails.ChartOfAccountIDAPTracking, clsDebitMemoDetails.Freight);
                clsChartOfAccount.UpdateCredit(clsDebitMemoDetails.ChartOfAccountIDAPFreight, clsDebitMemoDetails.Freight);

                // update Deposit & APTracking
                clsChartOfAccount.UpdateDebit(clsDebitMemoDetails.ChartOfAccountIDAPTracking, clsDebitMemoDetails.Deposit);
                clsChartOfAccount.UpdateCredit(clsDebitMemoDetails.ChartOfAccountIDAPVDeposit, clsDebitMemoDetails.Deposit);

                DebitMemoItems clsDebitMemoItems = new DebitMemoItems(base.Connection, base.Transaction);
                System.Data.DataTable dt = clsDebitMemoItems.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);
            }
        }
Esempio n. 3
0
        private void AddItemToInventory(long pvtDebitMemoID)
        {
            DebitMemoDetails clsDebitMemoDetails = Details(pvtDebitMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            DebitMemoItems clsDebitMemoItems = new DebitMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);

            ProductDetails clsProductDetails = new ProductDetails();
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;
            ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsDebitMemoItems.ListAsDataTable(pvtDebitMemoID, SortField: "DebitMemoItemID", SortOrder: SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decNewUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                //decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                //decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                //decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                clsProductDetails = clsProduct.Details1(clsDebitMemoDetails.BranchID, lngProductID);
                /*******************************************
				 * Add in the Purchase Price History based on Debit Memo
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsDebitMemoDetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = decNewUnitCost * (decItemQuantity / decQuantity);
                clsProductPackagePriceHistoryDetails.Price = -1;
                clsProductPackagePriceHistoryDetails.VAT = -1;
                clsProductPackagePriceHistoryDetails.EVAT = -1;
                clsProductPackagePriceHistoryDetails.LocalTax = -1;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on DebitMemo #: " + clsDebitMemoDetails.MemoNo;
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                /*******************************************
                 * Subtract from Inventory : Remove this since this is a Debit Memo
                 * ****************************************/
                //clsProduct.SubtractQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity);
                //}

                /*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, iBaseUnitID, (decItemQuantity * decNewUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, intProductUnitID, decNewUnitCost);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsDebitMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsDebitMemoDetails.MemoNo;
                clsInventoryDetails.ContactID = clsDebitMemoDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsDebitMemoDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.PDebitQuantity = decQuantity;
                clsInventoryDetails.PDebitCost = decAmount - decVAT;
                clsInventoryDetails.PDebitVAT = decAmount;

                clsInventory.Insert(clsInventoryDetails);

            }
        }
Esempio n. 4
0
		private void SetDataSource(ReportDocument Report)
		{
            long iID = 0;
            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["memoid"].ToString() != null)
                { iID = Convert.ToInt64(Request.QueryString["memoid"].ToString()); }
                else { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["memoid"].ToString(), Session.SessionID)); }
                lblReferrer.ToolTip = iID.ToString();
            }
            catch { iID = long.Parse(lblReferrer.ToolTip); }

			ReportDataset rptds = new ReportDataset();

			DebitMemos clsDebitMemos = new DebitMemos();
			System.Data.DataTable dt = clsDebitMemos.ListAsDataTable(DebitMemoID: iID);

            DebitMemoItems clsDebitMemoItems = new DebitMemoItems(clsDebitMemos.Connection, clsDebitMemos.Transaction);
            System.Data.DataTable dtitems = clsDebitMemoItems.ListAsDataTable(DebitMemoID: iID);
            
            clsDebitMemos.CommitAndDispose();

			foreach(System.Data.DataRow dr in dt.Rows)
			{
				DataRow drNew = rptds.DebitMemo.NewRow();
				
				foreach (DataColumn dc in rptds.DebitMemo.Columns)
					drNew[dc] = dr[dc.ColumnName]; 
				
				rptds.DebitMemo.Rows.Add(drNew);
			}

            foreach (System.Data.DataRow dr in dtitems.Rows)
			{
				DataRow drNew = rptds.DebitMemoItem.NewRow();
				
				foreach (DataColumn dc in rptds.DebitMemoItem.Columns)
					drNew[dc] = dr[dc.ColumnName]; 
				
				rptds.DebitMemoItem.Rows.Add(drNew);
			}

			Report.SetDataSource(rptds); 
			SetParameters(Report);
		}