Пример #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SaleGeneralReport objrep  = new SaleGeneralReport();
            rptViewer         objView = new rptViewer();

            objrep.SetParameterValue("@mindate", txtMinDate.Value);
            objrep.SetParameterValue("@maxdate", txtmaxdate.Value);
            SaleInvoiceBL obj = new SaleInvoiceBL()
            {
                mindate = Convert.ToDateTime(txtMinDate.Value),
                maxdate = Convert.ToDateTime(txtmaxdate.Value)
            };
            DataTable dt = obj.SelectByDate();

            if (dt.Rows.Count > 0)
            {
                objrep.SetDataSource(dt);

                objView.crptViewer.ReportSource = objrep;
                objView.WindowState             = FormWindowState.Maximized;
                objView.ShowDialog();
            }
            else
            {
                MessageBox.Show("No Record Found");
            }
        }
Пример #2
0
        private void btnCusName_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtCus.Text))
            {
                SaleByCusReport objSale = new SaleByCusReport();
                rptViewer       objView = new rptViewer();
                objSale.SetParameterValue("@CusID", txtCus.Text);
                SaleInvoiceBL objsal = new SaleInvoiceBL()
                {
                    CustomerID = Convert.ToInt32(txtCus.Text)
                };
                DataTable dt = objsal.SelectByCus();
                if (dt.Rows.Count > 0)
                {
                    objSale.SetDataSource(dt);
                    // btnCusprint.Visible = true;
                    objView.crptViewer.ReportSource = objSale;
                    objView.WindowState             = FormWindowState.Maximized;
                    objView.ShowDialog();
                    txtCus.Clear();
                }
                else
                {
                    MessageBox.Show("No Record Found");
                }
            }
            else if (!String.IsNullOrEmpty(txtinvoiceNo.Text))
            {
                saleInvoiceReport objSale = new saleInvoiceReport();
                rptViewer         objView = new rptViewer();
                objSale.SetParameterValue("@InvoiceNo", txtinvoiceNo.Text);
                SaleInvoiceBL obj = new SaleInvoiceBL()
                {
                    InvoiceNo = Convert.ToInt32(txtinvoiceNo.Text)
                };
                DataTable dt = obj.Search();
                if (dt.Rows.Count > 0)
                {
                    objSale.SetDataSource(dt);

                    objView.crptViewer.ReportSource = objSale;
                    objView.WindowState             = FormWindowState.Maximized;
                    objView.ShowDialog();
                    txtinvoiceNo.Clear();
                }
                //crptViewerSale.ReportSource = objSale;
                else
                {
                    MessageBox.Show("No Record Found");
                }
            }
            else
            {
                MessageBox.Show("Please Enter Customer ID OR Return Invoice");
            }
        }
Пример #3
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            SaleInvoiceBL objSale = new SaleInvoiceBL();
            DataTable     dt      = objSale.Addnew();

            if (dt.Rows.Count > 0)
            {
                txtInvoiceID.Text = Convert.ToString(dt.Rows[0]["Invoice#"]);
                LoadCus();
                LoadProd();
                btnSave.Enabled  = true;
                btnClear.Enabled = true;
                FormEnable();
                //LoadSaleDetail();
                LoadGridProd();
                LoadSalesman();
                SumCalculate();
                btnSave.Enabled = true;
                txtSalesman.Focus();
                btnNew.Enabled = false;
            }
        }
Пример #4
0
        //private void SumDetailProduct()
        //{
        //    decimal sum = 0;
        //    for (int i = 0; i < dgvProduct.Rows.Count; ++i)
        //    {
        //        sum += Convert.ToDecimal(resultTP);
        //    }
        //    resultGrand = Convert.ToDecimal(sum.ToString());

        //}



        private void btnSave_Click(object sender, EventArgs e)
        {
            SaleInvoiceBL objProd = new SaleInvoiceBL();

            for (int i = 0; i < dgvProduct.Rows.Count; ++i)
            {
                objProd.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objProd.Quantity  = Convert.ToInt32(dgvProduct.Rows[i].Cells[6].Value.ToString());
                objProd.UpdateProd();
            }

            PurchaseReturnBL objCtn = new PurchaseReturnBL();

            for (int i = 0; i < dgvProduct.Rows.Count; ++i)
            {
                objCtn.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objCtn.Ctn       = Convert.ToDecimal(dgvProduct.Rows[i].Cells[5].Value.ToString());
                objCtn.CtnUpdate();
            }



            SaleInvoiceBL objsale = new SaleInvoiceBL();
            decimal       Ssum    = 0;

            for (int i = 0; i < dgvProduct.Rows.Count; ++i)
            {
                objsale.InvoiceNo   = Convert.ToInt32(txtInvoiceID.Text);
                objsale.ProductID   = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objsale.Ctn         = Convert.ToDecimal(dgvProduct.Rows[i].Cells[5].Value.ToString());
                objsale.Quantity    = Convert.ToInt32(dgvProduct.Rows[i].Cells[6].Value.ToString());
                objsale.Discount    = Convert.ToDecimal(dgvProduct.Rows[i].Cells[7].Value.ToString());
                objsale.TotalAmount = Convert.ToDecimal(dgvProduct.Rows[i].Cells[8].Value.ToString());

                decimal TP = Convert.ToDecimal(dgvProduct.Rows[i].Cells[3].Value.ToString());
                objsale.RP = Convert.ToDecimal(dgvProduct.Rows[i].Cells[4].Value);
                decimal resultRP = (objsale.RP * objsale.Ctn) - objsale.Discount;
                decimal resultTP = (TP * objsale.Ctn);
                decimal detailP  = Convert.ToDecimal(resultRP - resultTP);
                objsale.DetailProfit = detailP;
                Ssum += resultTP;
                objsale.SaveDetail();
            }

            decimal       grandtotal    = Convert.ToDecimal(txtGrandTotal.Text);
            decimal       InvoiceProfit = grandtotal - Ssum;
            SaleInvoiceBL objmas        = new SaleInvoiceBL()
            {
                SaleDate     = DateTime.Parse(txtInvoiceDate.Text),
                GrandTotal   = Convert.ToDecimal(txtGrandTotal.Text),
                CustomerID   = Convert.ToInt32(txtCusId.Text),
                Payment      = Convert.ToDecimal(txtTotalPay.Text),
                DuePayment   = Convert.ToDecimal(txtDuePay.Text),
                OrderBy      = txtSalesman.Text,
                MasterProfit = InvoiceProfit
            };

            objmas.SaveMaster();

            SaleLedgerBL objLedger = new SaleLedgerBL();

            objLedger.Invoiceno  = Convert.ToInt32(txtInvoiceID.Text);
            objLedger.CustomerID = Convert.ToInt32(txtCusId.Text);
            objLedger.Credit     = Convert.ToDecimal(txtDuePay.Text);
            objLedger.Debit      = 0;



            objLedger.Date        = Convert.ToDateTime(txtInvoiceDate.Text);
            objLedger.Balance     = Convert.ToDecimal(txtnewBalance.Text);
            objLedger.Description = "Credit";
            objLedger.Save();
            (new SaleLedgerBL()).UpdateBalance(objLedger.Balance, objLedger.CustomerID);

            saleInvoiceReport objSale = new saleInvoiceReport();
            rptViewer         objview = new rptViewer();

            //objSale.SetDataSource =;
            objSale.SetParameterValue("@InvoiceNo", txtInvoiceID.Text);
            SaleInvoiceBL obj = new SaleInvoiceBL()
            {
                InvoiceNo = Convert.ToInt32(txtInvoiceID.Text)
            };
            DataTable dt = obj.Search();

            if (dt.Rows.Count > 0)
            {
                objSale.SetDataSource(dt);
            }
            objview.crptViewer.ReportSource = objSale;
            objview.WindowState             = FormWindowState.Normal;

            objview.ShowDialog();
            ClearForm();
            dgvProduct.DataSource = null;
            btnNew.Enabled        = true;
        }