Ejemplo n.º 1
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;
        }