示例#1
0
        private void AddItemToInventory(long CreditMemoID)
        {
            CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
            ERPConfig         clsERPConfig         = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails  clsERPConfigDetails  = clsERPConfig.Details();

            CreditMemoItems         clsCreditMemoItems         = new CreditMemoItems(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 = clsCreditMemoItems.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());

                /*******************************************
                 * Do not Add to Inventory coz this is a Debit Memo and no effect on inventory
                 * ****************************************/

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsCreditMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo       = clsCreditMemoDetails.CNNo;
                clsInventoryDetails.ContactID         = clsCreditMemoDetails.CustomerID;
                clsInventoryDetails.ContactCode       = clsCreditMemoDetails.CustomerCode;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SCreditQuantity   = decQuantity;
                clsInventoryDetails.SCreditCost       = decItemCost - decVAT;
                clsInventoryDetails.SCreditVAT        = decItemCost; //Sales Return with VAT

                clsInventory.Insert(clsInventoryDetails);
            }
            //myReader.Close();
        }
示例#2
0
        private void UpdateAccounts(long CreditMemoID)
        {
            try
            {
                CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
                ChartOfAccounts   clsChartOfAccount    = new ChartOfAccounts(base.Connection, base.Transaction);

                // update ChartOfAccountIDARTracking as credit
                clsChartOfAccount.UpdateCredit(clsCreditMemoDetails.ChartOfAccountIDARTracking, clsCreditMemoDetails.SubTotal);

                // update Deposit & APContra
                clsChartOfAccount.UpdateDebit(clsCreditMemoDetails.ChartOfAccountIDARContra, clsCreditMemoDetails.Discount);

                // update Freight & APTracking
                clsChartOfAccount.UpdateDebit(clsCreditMemoDetails.ChartOfAccountIDARTracking, clsCreditMemoDetails.Freight);
                clsChartOfAccount.UpdateCredit(clsCreditMemoDetails.ChartOfAccountIDARFreight, clsCreditMemoDetails.Freight);

                // update Deposit & APTracking
                clsChartOfAccount.UpdateDebit(clsCreditMemoDetails.ChartOfAccountIDARTracking, clsCreditMemoDetails.Deposit);
                clsChartOfAccount.UpdateCredit(clsCreditMemoDetails.ChartOfAccountIDARVDeposit, clsCreditMemoDetails.Deposit);

                CreditMemoItems       clsCreditMemoItems = new CreditMemoItems(base.Connection, base.Transaction);
                System.Data.DataTable dt = clsCreditMemoItems.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);
            }
        }
示例#3
0
 private void UpdateFooter(CreditMemoDetails clsCreditMemoDetails)
 {
     lblSODiscount.Text = clsCreditMemoDetails.Discount.ToString("#,##0.#0");
     lblSOVatableAmount.Text = clsCreditMemoDetails.VatableAmount.ToString("#,##0.#0");
     txtSOFreight.Text = clsCreditMemoDetails.Freight.ToString("#,##0.#0");
     txtSODeposit.Text = clsCreditMemoDetails.Deposit.ToString("#,##0.#0");
     lblSOSubTotal.Text = Convert.ToDecimal(clsCreditMemoDetails.SubTotal - clsCreditMemoDetails.VAT).ToString("#,##0.#0");
     lblSOVAT.Text = clsCreditMemoDetails.VAT.ToString("#,##0.#0");
     lblSOTotal.Text = clsCreditMemoDetails.SubTotal.ToString("#,##0.#0");
 }
示例#4
0
        public long Insert(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig           clsERPConfig           = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "INSERT INTO tblSOCreditMemo (" +
                             "CNNo, " +
                             "CNDate, " +
                             "CustomerID, " +
                             "CustomerCode, " +
                             "CustomerContact, " +
                             "CustomerAddress, " +
                             "CustomerTelephoneNo, " +
                             "CustomerModeOfTerms, " +
                             "CustomerTerms, " +
                             "RequiredPostingDate, " +
                             "BranchID, " +
                             "SellerID, " +
                             "SellerName, " +
                             "SOReturnStatus, " +
                             "CreditMemoStatus, " +
                             "Remarks, " +
                             "ChartOfAccountIDARTracking, " +
                             "ChartOfAccountIDARBills, " +
                             "ChartOfAccountIDARFreight, " +
                             "ChartOfAccountIDARVDeposit, " +
                             "ChartOfAccountIDARContra, " +
                             "ChartOfAccountIDARLatePayment" +
                             ") VALUES (" +
                             "@CNNo, " +
                             "@CNDate, " +
                             "@CustomerID, " +
                             "@CustomerCode, " +
                             "@CustomerContact, " +
                             "@CustomerAddress, " +
                             "@CustomerTelephoneNo, " +
                             "@CustomerModeOfTerms, " +
                             "@CustomerTerms, " +
                             "@RequiredPostingDate, " +
                             "@BranchID, " +
                             "@SellerID, " +
                             "@SellerName, " +
                             "@SOReturnStatus, " +
                             "@CreditMemoStatus, " +
                             "@Remarks, " +
                             "@ChartOfAccountIDARTracking, " +
                             "@ChartOfAccountIDARBills, " +
                             "@ChartOfAccountIDARFreight, " +
                             "@ChartOfAccountIDARVDeposit, " +
                             "@ChartOfAccountIDARContra, " +
                             "@ChartOfAccountIDARLatePayment" +
                             ");";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                Int64 iID = 0;

                while (myReader.Read())
                {
                    iID = myReader.GetInt64(0);
                }

                myReader.Close();

                return(iID);
            }

            catch (Exception ex)
            {
                {
                }

                throw base.ThrowException(ex);
            }
        }
示例#5
0
        public CreditMemoDetails Details(long CreditMemoID)
        {
            try
            {
                string SQL = SQLSelect() + "AND CreditMemoID = @CreditMemoID;";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CreditMemoID", CreditMemoID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                CreditMemoDetails Details = new CreditMemoDetails();

                while (myReader.Read())
                {
                    Details.CreditMemoID        = CreditMemoID;
                    Details.CNNo                = "" + myReader["CNNo"].ToString();
                    Details.CNDate              = myReader.GetDateTime("CNDate");
                    Details.CustomerID          = myReader.GetInt64("CustomerID");
                    Details.CustomerCode        = "" + myReader["CustomerCode"].ToString();
                    Details.CustomerContact     = "" + myReader["CustomerContact"].ToString();
                    Details.CustomerAddress     = "" + myReader["CustomerAddress"].ToString();
                    Details.CustomerTelephoneNo = "" + myReader["CustomerTelephoneNo"].ToString();
                    Details.CustomerModeOfTerms = myReader.GetInt16("CustomerModeofTerms");
                    Details.CustomerTerms       = myReader.GetInt16("CustomerTerms");
                    Details.RequiredPostingDate = myReader.GetDateTime("RequiredPostingDate");
                    Details.BranchID            = myReader.GetInt16("BranchID");
                    Details.BranchCode          = "" + myReader["BranchCode"].ToString();
                    Details.BranchName          = "" + myReader["BranchName"].ToString();
                    Details.BranchAddress       = "" + myReader["BranchAddress"].ToString();
                    Details.SellerID            = myReader.GetInt64("SellerID");
                    Details.SellerName          = "" + myReader["SellerName"].ToString();
                    Details.SubTotal            = myReader.GetDecimal("SubTotal");
                    Details.Discount            = myReader.GetDecimal("Discount");
                    Details.DiscountApplied     = myReader.GetDecimal("DiscountApplied");
                    Details.DiscountType        = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType"));
                    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.Freight                       = myReader.GetDecimal("Freight");
                    Details.Deposit                       = myReader.GetDecimal("Deposit");
                    Details.PaidAmount                    = myReader.GetDecimal("PaidAmount");
                    Details.UnpaidAmount                  = myReader.GetDecimal("UnpaidAmount");
                    Details.TotalItemDiscount             = myReader.GetDecimal("TotalItemDiscount");
                    Details.CreditMemoStatus              = (CreditMemoStatus)Enum.Parse(typeof(CreditMemoStatus), myReader.GetString("CreditMemoStatus"));
                    Details.Remarks                       = "" + myReader["Remarks"].ToString();
                    Details.CustomerDocNo                 = "" + myReader["CustomerDocNo"].ToString();
                    Details.PostingDate                   = myReader.GetDateTime("PostingDate");
                    Details.ChartOfAccountIDARTracking    = myReader.GetInt16("ChartOfAccountIDARTracking");
                    Details.ChartOfAccountIDARFreight     = myReader.GetInt16("ChartOfAccountIDARFreight");
                    Details.ChartOfAccountIDARVDeposit    = myReader.GetInt16("ChartOfAccountIDARVDeposit");
                    Details.ChartOfAccountIDARContra      = myReader.GetInt16("ChartOfAccountIDARContra");
                    Details.ChartOfAccountIDARLatePayment = myReader.GetInt16("ChartOfAccountIDARLatePayment");
                }

                myReader.Close();

                return(Details);
            }

            catch (Exception ex)
            {
                {
                }

                throw base.ThrowException(ex);
            }
        }
示例#6
0
        public void Update(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig           clsERPConfig           = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "UPDATE tblSOCreditMemo SET " +
                             "CNNo				=	@CNNo, "+
                             "CNDate				=	@CNDate, "+
                             "CustomerID				=	@CustomerID, "+
                             "CustomerCode			=	@CustomerCode, "+
                             "CustomerContact		=	@CustomerContact, "+
                             "CustomerAddress		=	@CustomerAddress, "+
                             "CustomerTelephoneNo	=	@CustomerTelephoneNo, "+
                             "CustomerModeOfTerms	=	@CustomerModeOfTerms, "+
                             "CustomerTerms			=	@CustomerTerms, "+
                             "RequiredPostingDate	=	@RequiredPostingDate, "+
                             "BranchID				=	@BranchID, "+
                             "SellerID			=	@SellerID, "+
                             "SellerName          =   @SellerName, " +
                             "Remarks                =   @Remarks, " +
                             "ChartOfAccountIDARTracking     = @ChartOfAccountIDARTracking, " +
                             "ChartOfAccountIDARBills        = @ChartOfAccountIDARBills, " +
                             "ChartOfAccountIDARFreight      = @ChartOfAccountIDARFreight, " +
                             "ChartOfAccountIDARVDeposit     = @ChartOfAccountIDARVDeposit, " +
                             "ChartOfAccountIDARContra       = @ChartOfAccountIDARContra, " +
                             "ChartOfAccountIDARLatePayment  = @ChartOfAccountIDARLatePayment " +
                             "WHERE CreditMemoID = @CreditMemoID;";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);
                cmd.Parameters.AddWithValue("@CreditMemoID", Details.CreditMemoID);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                {
                }

                throw base.ThrowException(ex);
            }
        }
示例#7
0
        private void UpdateSODiscount()
        {
            CreditMemoDetails clsCreditMemoDetails = new CreditMemoDetails();
            clsCreditMemoDetails.CreditMemoID = Convert.ToInt64(lblCreditMemoID.Text);
            clsCreditMemoDetails.DiscountApplied = Convert.ToDecimal(txtSODiscountApplied.Text);
            clsCreditMemoDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboSODiscountType.SelectedItem.Value);

            CreditMemos clsCreditMemos = new CreditMemos();
            clsCreditMemos.UpdateDiscount(clsCreditMemoDetails.CreditMemoID, clsCreditMemoDetails.DiscountApplied, clsCreditMemoDetails.DiscountType);
            clsCreditMemos.SynchronizeAmount(Convert.ToInt64(lblCreditMemoID.Text));
            clsCreditMemoDetails = clsCreditMemos.Details(Convert.ToInt64(lblCreditMemoID.Text));
            clsCreditMemos.CommitAndDispose();

            UpdateFooter(clsCreditMemoDetails);
        }
示例#8
0
        private void UpdateDeposit()
        {
            CreditMemoDetails clsCreditMemoDetails = new CreditMemoDetails();
            clsCreditMemoDetails.CreditMemoID = Convert.ToInt64(lblCreditMemoID.Text);
            clsCreditMemoDetails.Deposit = Convert.ToDecimal(txtSODeposit.Text);

            CreditMemos clsCreditMemos = new CreditMemos();
            clsCreditMemos.UpdateDeposit(clsCreditMemoDetails.CreditMemoID, clsCreditMemoDetails.Deposit);
            clsCreditMemos.SynchronizeAmount(clsCreditMemoDetails.CreditMemoID);
            clsCreditMemoDetails = clsCreditMemos.Details(clsCreditMemoDetails.CreditMemoID);
            clsCreditMemos.CommitAndDispose();

            UpdateFooter(clsCreditMemoDetails);
        }
示例#9
0
        private long SaveRecord()
        {
            CreditMemos clsCreditMemos = new CreditMemos();
            clsCreditMemos.GetConnection();
            lblReturnNo.Text = Constants.SALES_CREDITMEMO_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsCreditMemos.LastTransactionNo();

            CreditMemoDetails clsDetails = new CreditMemoDetails();

            clsDetails.CNNo = lblReturnNo.Text;
            clsDetails.CNDate = Convert.ToDateTime(lblReturnDate.Text);
            clsDetails.CustomerID = Convert.ToInt64(cboCustomer.SelectedItem.Value);
            clsDetails.CustomerCode = cboCustomer.SelectedItem.Text;
            clsDetails.CustomerContact = txtCustomerContact.Text;
            clsDetails.CustomerAddress = txtCustomerAddress.Text;
            clsDetails.CustomerTelephoneNo = txtCustomerTelephoneNo.Text;
            clsDetails.CustomerTerms = Convert.ToInt32(lblTerms.Text);
            switch (lblModeOfterms.Text)
            {
                case "Days":
                    clsDetails.CustomerModeOfTerms = 0;
                    break;
                case "Months":
                    clsDetails.CustomerModeOfTerms = 1;
                    break;
                case "Years":
                    clsDetails.CustomerModeOfTerms = 2;
                    break;
            }
            clsDetails.RequiredPostingDate = Convert.ToDateTime(txtRequiredReturnDate.Text);
            clsDetails.BranchID = Convert.ToInt16(cboBranch.SelectedItem.Value);
            clsDetails.SellerID = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.SellerName = Session["Name"].ToString();
            clsDetails.CreditMemoStatus = CreditMemoStatus.Open;
            clsDetails.Remarks = txtRemarks.Text;

            long id = clsCreditMemos.Insert(clsDetails);
            clsCreditMemos.CommitAndDispose();

            return id;
        }
示例#10
0
        private void SaveRecord()
        {
            CreditMemoDetails clsDetails = new CreditMemoDetails();

            clsDetails.CreditMemoID = Convert.ToInt64(lblCreditMemoID.Text);
            clsDetails.CNNo = lnkReturnNo.Text;
            clsDetails.CNDate = Convert.ToDateTime(lblReturnDate.Text);
            clsDetails.CustomerID = Convert.ToInt64(cboCustomer.SelectedItem.Value);
            clsDetails.CustomerCode = cboCustomer.SelectedItem.Text;
            clsDetails.CustomerContact = txtCustomerContact.Text;
            clsDetails.CustomerAddress = txtCustomerAddress.Text;
            clsDetails.CustomerTelephoneNo = txtCustomerTelephoneNo.Text;
            switch (lblModeOfterms.Text)
            {
                case "Days":
                    clsDetails.CustomerModeOfTerms = 0;
                    break;
                case "Months":
                    clsDetails.CustomerModeOfTerms = 1;
                    break;
                case "Years":
                    clsDetails.CustomerModeOfTerms = 2;
                    break;
            }
            clsDetails.RequiredPostingDate = Convert.ToDateTime(txtRequiredReturnDate.Text);
            clsDetails.BranchID = Convert.ToInt16(cboBranch.SelectedItem.Value);
            clsDetails.SellerID = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.SellerName = Session["Name"].ToString();
            clsDetails.CreditMemoStatus = CreditMemoStatus.Open;
            clsDetails.Remarks = txtRemarks.Text;

            CreditMemos clsCreditMemos = new CreditMemos();
            clsCreditMemos.Update(clsDetails);
            clsCreditMemos.CommitAndDispose();
        }
示例#11
0
        public long Insert(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "INSERT INTO tblSOCreditMemo (" +
                                "CNNo, " +
                                "CNDate, " +
                                "CustomerID, " +
                                "CustomerCode, " +
                                "CustomerContact, " +
                                "CustomerAddress, " +
                                "CustomerTelephoneNo, " +
                                "CustomerModeOfTerms, " +
                                "CustomerTerms, " +
                                "RequiredPostingDate, " +
                                "BranchID, " +
                                "SellerID, " +
                                "SellerName, " +
                                "SOReturnStatus, " +
                                "CreditMemoStatus, " +
                                "Remarks, " +
                                "ChartOfAccountIDARTracking, " +
                                "ChartOfAccountIDARBills, " +
                                "ChartOfAccountIDARFreight, " +
                                "ChartOfAccountIDARVDeposit, " +
                                "ChartOfAccountIDARContra, " +
                                "ChartOfAccountIDARLatePayment" +
                            ") VALUES (" +
                                "@CNNo, " +
                                "@CNDate, " +
                                "@CustomerID, " +
                                "@CustomerCode, " +
                                "@CustomerContact, " +
                                "@CustomerAddress, " +
                                "@CustomerTelephoneNo, " +
                                "@CustomerModeOfTerms, " +
                                "@CustomerTerms, " +
                                "@RequiredPostingDate, " +
                                "@BranchID, " +
                                "@SellerID, " +
                                "@SellerName, " +
                                "@SOReturnStatus, " +
                                "@CreditMemoStatus, " +
                                "@Remarks, " +
                                "@ChartOfAccountIDARTracking, " +
                                "@ChartOfAccountIDARBills, " +
                                "@ChartOfAccountIDARFreight, " +
                                "@ChartOfAccountIDARVDeposit, " +
                                "@ChartOfAccountIDARContra, " +
                                "@ChartOfAccountIDARLatePayment" +
                            ");";

                

                MySqlCommand cmd = new MySqlCommand();
                
                
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                Int64 iID = 0;

                while (myReader.Read())
                {
                    iID = myReader.GetInt64(0);
                }

                myReader.Close();

                return iID;
            }

            catch (Exception ex)
            {
                
                
                {
                    
                    
                    
                    
                }

                throw base.ThrowException(ex);
            }
        }
示例#12
0
        public CreditMemoDetails Details(long CreditMemoID)
        {
            try
            {
                string SQL = SQLSelect() + "AND CreditMemoID = @CreditMemoID;";

                

                MySqlCommand cmd = new MySqlCommand();
                
                
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CreditMemoID", CreditMemoID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                CreditMemoDetails Details = new CreditMemoDetails();

                while (myReader.Read())
                {
                    Details.CreditMemoID = CreditMemoID;
                    Details.CNNo = "" + myReader["CNNo"].ToString();
                    Details.CNDate = myReader.GetDateTime("CNDate");
                    Details.CustomerID = myReader.GetInt64("CustomerID");
                    Details.CustomerCode = "" + myReader["CustomerCode"].ToString();
                    Details.CustomerContact = "" + myReader["CustomerContact"].ToString();
                    Details.CustomerAddress = "" + myReader["CustomerAddress"].ToString();
                    Details.CustomerTelephoneNo = "" + myReader["CustomerTelephoneNo"].ToString();
                    Details.CustomerModeOfTerms = myReader.GetInt16("CustomerModeofTerms");
                    Details.CustomerTerms = myReader.GetInt16("CustomerTerms");
                    Details.RequiredPostingDate = myReader.GetDateTime("RequiredPostingDate");
                    Details.BranchID = myReader.GetInt16("BranchID");
                    Details.BranchCode = "" + myReader["BranchCode"].ToString();
                    Details.BranchName = "" + myReader["BranchName"].ToString();
                    Details.BranchAddress = "" + myReader["BranchAddress"].ToString();
                    Details.SellerID = myReader.GetInt64("SellerID");
                    Details.SellerName = "" + myReader["SellerName"].ToString();
                    Details.SubTotal = myReader.GetDecimal("SubTotal");
                    Details.Discount = myReader.GetDecimal("Discount");
                    Details.DiscountApplied = myReader.GetDecimal("DiscountApplied");
                    Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType"));
                    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.Freight = myReader.GetDecimal("Freight");
                    Details.Deposit = myReader.GetDecimal("Deposit");
                    Details.PaidAmount = myReader.GetDecimal("PaidAmount");
                    Details.UnpaidAmount = myReader.GetDecimal("UnpaidAmount");
                    Details.TotalItemDiscount = myReader.GetDecimal("TotalItemDiscount");
                    Details.CreditMemoStatus = (CreditMemoStatus)Enum.Parse(typeof(CreditMemoStatus), myReader.GetString("CreditMemoStatus"));
                    Details.Remarks = "" + myReader["Remarks"].ToString();
                    Details.CustomerDocNo = "" + myReader["CustomerDocNo"].ToString();
                    Details.PostingDate = myReader.GetDateTime("PostingDate");
                    Details.ChartOfAccountIDARTracking = myReader.GetInt16("ChartOfAccountIDARTracking");
                    Details.ChartOfAccountIDARFreight = myReader.GetInt16("ChartOfAccountIDARFreight");
                    Details.ChartOfAccountIDARVDeposit = myReader.GetInt16("ChartOfAccountIDARVDeposit");
                    Details.ChartOfAccountIDARContra = myReader.GetInt16("ChartOfAccountIDARContra");
                    Details.ChartOfAccountIDARLatePayment = myReader.GetInt16("ChartOfAccountIDARLatePayment");
                }

                myReader.Close();

                return Details;
            }

            catch (Exception ex)
            {
                
                
                {
                    
                    
                    
                    
                }

                throw base.ThrowException(ex);
            }
        }
示例#13
0
        public void Update(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "UPDATE tblSOCreditMemo SET " +
                                "CNNo				=	@CNNo, " +
                                "CNDate				=	@CNDate, " +
                                "CustomerID				=	@CustomerID, " +
                                "CustomerCode			=	@CustomerCode, " +
                                "CustomerContact		=	@CustomerContact, " +
                                "CustomerAddress		=	@CustomerAddress, " +
                                "CustomerTelephoneNo	=	@CustomerTelephoneNo, " +
                                "CustomerModeOfTerms	=	@CustomerModeOfTerms, " +
                                "CustomerTerms			=	@CustomerTerms, " +
                                "RequiredPostingDate	=	@RequiredPostingDate, " +
                                "BranchID				=	@BranchID, " +
                                "SellerID			=	@SellerID, " +
                                "SellerName          =   @SellerName, " +
                                "Remarks                =   @Remarks, " +
                                "ChartOfAccountIDARTracking     = @ChartOfAccountIDARTracking, " +
                                "ChartOfAccountIDARBills        = @ChartOfAccountIDARBills, " +
                                "ChartOfAccountIDARFreight      = @ChartOfAccountIDARFreight, " +
                                "ChartOfAccountIDARVDeposit     = @ChartOfAccountIDARVDeposit, " +
                                "ChartOfAccountIDARContra       = @ChartOfAccountIDARContra, " +
                                "ChartOfAccountIDARLatePayment  = @ChartOfAccountIDARLatePayment " +
                            "WHERE CreditMemoID = @CreditMemoID;";

                

                MySqlCommand cmd = new MySqlCommand();
                
                
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);
                cmd.Parameters.AddWithValue("@CreditMemoID", Details.CreditMemoID);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                
                
                {
                    
                    
                    
                    
                }

                throw base.ThrowException(ex);
            }
        }