예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TransSalesModel objSaleVch = new TransSalesModel();

            if (tbxVoucherNumber.Text.Trim() == "")
            {
                MessageBox.Show("Voucher Number Can Not Be Blank!");
                return;
            }
            objSaleVch.VoucherType      = tbxVoucherType.Text.Trim();
            objSaleVch.SaleDate         = Convert.ToDateTime(dtDate.Text);
            objSaleVch.Terms            = cbxTerms.SelectedItem.ToString();
            objSaleVch.VoucherNumber    = Convert.ToInt64(tbxVoucherNumber.Text.Trim() == string.Empty ? "0" : tbxVoucherNumber.Text.Trim());
            objSaleVch.BillNo           = Convert.ToInt64(tbxBillNo.Text.Trim() == string.Empty ? "0" : tbxBillNo.Text.Trim());
            objSaleVch.LedgerId         = objAccBL.GetLedgerIdByAccountName(tbxParty.Text.Trim());
            objSaleVch.SalesType        = tbxSaleType.Text.Trim() == null?string.Empty:tbxSaleType.Text.Trim();
            objSaleVch.MatCentre        = tbxMatcenter.Text.Trim() == null?string.Empty: tbxMatcenter.Text.Trim();
            objSaleVch.PriceList        = cbxPriceList.Text.Trim() == null?string.Empty: cbxPriceList.Text.Trim();
            objSaleVch.Narration        = tbxNarration.Text.Trim() == null?string.Empty :tbxNarration.Text.Trim();
            objSaleVch.TotalAmount      = Convert.ToDecimal(Amount.SummaryItem.SummaryValue);
            objSaleVch.TotalFree        = Convert.ToDecimal(colFree.SummaryItem.SummaryValue);
            objSaleVch.TotalBasicAmount = Convert.ToDecimal(colBasicAmt.SummaryItem.SummaryValue);
            objSaleVch.TotalDisAmount   = Convert.ToDecimal(colDisAmt.SummaryItem.SummaryValue);
            objSaleVch.TotalTaxAmount   = Convert.ToDecimal(colTaxAmont.SummaryItem.SummaryValue);
            objSaleVch.TotalQty         = Convert.ToDecimal(Qty.SummaryItem.SummaryValue);
            objSaleVch.BSTotalAmount    = Convert.ToDecimal(BSAmount.SummaryItem.SummaryValue);

            //Items Details
            Item_VoucherModel        objSaleItem;
            List <Item_VoucherModel> lstSaleItems = new List <Item_VoucherModel>();

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

                objSaleItem                    = new Item_VoucherModel();
                objSaleItem.ITM_Id             = objIMBL.GetItemIdByItemName(row["Item"].ToString() == null?string.Empty: row["Item"].ToString());
                objSaleItem.LedgerId           = objAccBL.GetLedgerIdByAccountName(row["Particulars"].ToString() == null ? string.Empty : row["Particulars"].ToString());
                objSaleItem.Qty                = Convert.ToDecimal(row["Qty"].ToString() == string.Empty?"0.00": row["Qty"]);
                objSaleItem.Unit               = row["Unit"].ToString() == null ? string.Empty : row["Unit"].ToString();
                objSaleItem.Per                = row["Per"].ToString() == null ? string.Empty : row["Per"].ToString();
                objSaleItem.Price              = Convert.ToDecimal(row["Price"].ToString() == string.Empty ? "0.00" : row["Price"].ToString());
                objSaleItem.Batch              = row["Batch"].ToString() == null ? string.Empty : row["Batch"].ToString();
                objSaleItem.Free               = Convert.ToDecimal(row["Free"].ToString() == string.Empty ? "0.00" : row["Free"].ToString());
                objSaleItem.BasicAmt           = Convert.ToDecimal(row["BasicAmt"].ToString() == string.Empty ? "0.00" : row["BasicAmt"].ToString());
                objSaleItem.DiscountPercentage = Convert.ToDecimal(row["DiscountPercentage"].ToString() == string.Empty ? "0.00" : row["DiscountPercentage"].ToString());
                objSaleItem.DiscountAmount     = Convert.ToDecimal(row["DiscountAmount"].ToString() == string.Empty ? "0.00" : row["DiscountAmount"].ToString());
                objSaleItem.TaxAmount          = Convert.ToDecimal(row["TaxAmount"].ToString() == string.Empty ? "0.00" : row["TaxAmount"].ToString());
                objSaleItem.Amount             = Convert.ToDecimal(row["Amount"].ToString() == string.Empty?"0.00":row["Amount"].ToString());
                if (objSaleVch.Trans_Sales_Id != 0)
                {
                    objSaleItem.Item_ID  = Convert.ToInt64(row["Item_ID"].ToString() == string.Empty ? "0" : row["Item_ID"].ToString());
                    objSaleItem.ParentId = Convert.ToInt64(row["ParentId"].ToString() == string.Empty ? "0" : row["ParentId"].ToString());
                }
                lstSaleItems.Add(objSaleItem);
            }

            objSaleVch.SalesItem_Voucher = lstSaleItems;
            //Bill Sundry Details
            BillSundry_VoucherModel        objSaleBS;
            List <BillSundry_VoucherModel> lstSaleBS = new List <BillSundry_VoucherModel>();

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

                objSaleBS            = new BillSundry_VoucherModel();
                objSaleBS.BS_Id      = objBSBL.GetBSIdByBSName(row["BillSundry"].ToString() == null?string.Empty: row["BillSundry"].ToString());
                objSaleBS.Percentage = Convert.ToDecimal(row["Percentage"].ToString() == string.Empty?"0.00":row["Percentage"].ToString());
                objSaleBS.Extra      = row["Extra"].ToString() == null ? string.Empty : row["Extra"].ToString();
                objSaleBS.Amount     = Convert.ToDecimal(row["Amount"].ToString() == string.Empty?"0.00": row["Amount"].ToString());

                lstSaleBS.Add(objSaleBS);
            }
            objSaleVch.SalesBillSundry_Voucher = lstSaleBS;

            bool isSuccess = objSVBL.SaveSalesVoucher(objSaleVch);

            if (isSuccess)
            {
                ledgerPostingAdd();
                MessageBox.Show("Saved Successfully!");
                SalesId = 0;
                //ClearControls();
            }
        }
예제 #2
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();
            }
        }