Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TransSalesModel objSales = new TransSalesModel();

            if (tbxVchNo.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }

            objSales.Series        = tbxSeries.Text.Trim();
            objSales.SalesType     = tbxSalesType.Text.Trim();
            objSales.SaleDate      = Convert.ToDateTime(dtDate.Text);
            objSales.VoucherNumber = Convert.ToInt32(tbxVchNo.Text.Trim());
            objSales.Party         = tbxParty.Text.Trim();
            objSales.MatCentre     = tbxMatCentre.Text.Trim();
            objSales.Narration     = tbxNarration.Text.Trim();

            objSales.TotalAmount = Convert.ToDecimal(Amount.SummaryItem.SummaryValue);
            objSales.TotalQty    = Convert.ToInt32(Qty.SummaryItem.SummaryValue);

            //Bill Number and Due date not captured- check with Ravi if these are required


            //Items
            Item_VoucherModel        objItem;
            List <Item_VoucherModel> lstItems = new List <Item_VoucherModel>();

            for (int i = 0; i < gdvItem.DataRowCount; i++)
            {
                DataRow row = gdvItem.GetDataRow(i);

                objItem      = new Item_VoucherModel();
                objItem.Item = row["Item"].ToString();

                objItem.Qty    = Convert.ToDecimal(row["Qty"]);
                objItem.Unit   = row["Unit"].ToString();
                objItem.Amount = Convert.ToDecimal(row["Amount"].ToString());
                objItem.Price  = Convert.ToDecimal(row["Price"].ToString());
                lstItems.Add(objItem);
            }

            objSales.SalesItem_Voucher = lstItems;

            //Bill Sundry
            BillSundry_VoucherModel        objBS;
            List <BillSundry_VoucherModel> lstBS = new List <BillSundry_VoucherModel>();

            for (int i = 0; i < gridBs.DataRowCount; i++)
            {
                DataRow row = gridBs.GetDataRow(i);

                objBS            = new BillSundry_VoucherModel();
                objBS.BillSundry = row["BillSundry"].ToString();
                objBS.Percentage = Convert.ToDecimal(row["Percentage"]);
                objBS.Amount     = Convert.ToDecimal(row["Amount"]);
                objBS.Type       = row["Extra"].ToString();

                lstBS.Add(objBS);
            }

            objSales.BSTotalAmount = Convert.ToDecimal(BSAmount.SummaryItem.SummaryValue);

            objSales.SalesBillSundry_Voucher = lstBS;

            objSalesVoucher = new SalesVoucherBL();

            bool isSuccess = objSalesVoucher.SaveSalesVoucher(objSales);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
                //   Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!");
                // d.ShowDialog();
            }
        }