Exemple #1
0
        private void search()
        {
            BLLInvoice obj_BLLInvoice = new BLLInvoice();

            DateTime dateTime_From = Convert.ToDateTime(dtp_InvoiceDateFrom.Value);
            DateTime dateTime_To   = Convert.ToDateTime(dtp_InvoiceDateTo.Value.Date.AddHours(23.9));

            DateTime dateTime_Due_Date = DEGlobal.dateTime_DefaultDate;

            DateTime dateTime_Current = DEGlobal.dateTime_ToDayDate;

            String str_InvoiceNo = string.Empty;

            int int_Customer_Id = 0;

            int int_CustomerGroup_Id = 0;

            int int_InvoiceType_Id = 0;

            String user = string.Empty;

            try
            {
                int_CustomerGroup_Id = Convert.ToInt32(cbx_CustomerGroup.SelectedItem.Col3);
                //customer.Catagory_Description = cbx_CustomerGroup.SelectedText;
            }
            catch (Exception ex)
            {
                int_CustomerGroup_Id = 0;
                //customer.Customer_Description = "";
            }

            try
            {
                int_Customer_Id = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
            }
            catch (Exception ex)
            {
                int_Customer_Id = 0;
            }

            try
            {
                user = Convert.ToString(cbx_Cashier.SelectedItem.Col2);
            }
            catch (Exception ex)
            {
                user = string.Empty;
            }

            DataTable dt_InvoiceList = new DataTable();

            ////////////////////////////// By Customer
            if (rdo_Customer.Checked)
            {
                if (rdo_All.Checked == true)
                {
                    String str_PONo = "";

                    if (rdo_Cash.Checked == true)
                    {
                        int_InvoiceType_Id = 1;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilter(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    else if (rdo_Credit.Checked == true)
                    {
                        int_InvoiceType_Id = 2;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilter(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    else if (rdo_Consignment.Checked == true)
                    {
                        int_InvoiceType_Id = 3;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilter(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    //////////////////////
                }
                else
                {
                    Boolean bool_isPaid;

                    if (rdo_Paid.Checked == true)
                    {
                        bool_isPaid = true;
                    }
                    else
                    {
                        bool_isPaid = false;
                    }

                    if (rdo_Cash.Checked == true)
                    {
                        int_InvoiceType_Id = 1;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaid(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                    else if (rdo_Credit.Checked == true)
                    {
                        int_InvoiceType_Id = 2;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaid(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                    else if (rdo_Consignment.Checked == true)
                    {
                        int_InvoiceType_Id = 3;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaid(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                } //// end of (rdo_all.checked == false)
                  ////////////// end of By Customer
            }
            /////////////////    By Customer Group
            else
            {
                if (rdo_All.Checked == true)
                {
                    String str_PONo = "";

                    if (rdo_Cash.Checked == true)
                    {
                        int_InvoiceType_Id = 1;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDateByCustomerGroup(dateTime_From, dateTime_To, dateTime_Current, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    else if (rdo_Credit.Checked == true)
                    {
                        int_InvoiceType_Id = 2;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDateByCustomerGroup(dateTime_From, dateTime_To, dateTime_Current, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    else if (rdo_Consignment.Checked == true)
                    {
                        int_InvoiceType_Id = 3;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, str_PONo);
                        }
                        else
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDateByCustomerGroup(dateTime_From, dateTime_To, dateTime_Current, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                        }
                    }
                    //////////////////////
                }
                else
                {
                    Boolean bool_isPaid;

                    if (rdo_Paid.Checked == true)
                    {
                        bool_isPaid = true;
                    }
                    else
                    {
                        bool_isPaid = false;
                    }

                    if (rdo_Cash.Checked == true)
                    {
                        int_InvoiceType_Id = 1;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaidByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                    else if (rdo_Credit.Checked == true)
                    {
                        int_InvoiceType_Id = 2;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaidByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                    else if (rdo_Consignment.Checked == true)
                    {
                        int_InvoiceType_Id = 3;

                        if (chb_NotPaidAndOverDueDate.Checked == false)
                        {
                            if (dtp_DueDate.Checked == true)
                            {
                                dateTime_Due_Date = dtp_DueDate.Value.Date;
                            }
                            dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterPaidOrNotPaidByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, dateTime_Due_Date, user, bool_isPaid);
                        }
                        else
                        {
                            //dt_InvoiceList = obj_BLLInvoice.LoadInvoiceTableForAllDataByFilterNotPaidOverDueDate(dateTime_From, dateTime_To, dateTime_Current, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user);
                        }
                    }
                }
            }

            bindReport(dt_InvoiceList);
        }
        private void search()
        {
            BLLInvoice obj_BLLInvoice = new BLLInvoice();

            DateTime dateTime_From = Convert.ToDateTime(dtp_PaidDateFrom.Value);
            DateTime dateTime_To   = Convert.ToDateTime(dtp_PaidDateTo.Value.Date.AddHours(23.9));

            //DateTime dateTime_Due_Date = DEGlobal.dateTime_DefaultDate;

            DateTime dateTime_Current = DEGlobal.dateTime_ToDayDate;

            String str_InvoiceNo = string.Empty;

            int int_Customer_Id = 0;

            int int_CustomerGroup_Id = 0;

            int int_InvoiceType_Id = 0;

            String user = string.Empty;

            try
            {
                int_CustomerGroup_Id = Convert.ToInt32(cbx_CustomerGroup.SelectedItem.Col3);
                //customer.Catagory_Description = cbx_CustomerGroup.SelectedText;
            }
            catch (Exception ex)
            {
                int_CustomerGroup_Id = 0;
                //customer.Customer_Description = "";
            }

            try
            {
                int_Customer_Id = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
            }
            catch (Exception ex)
            {
                int_Customer_Id = 0;
            }

            try
            {
                user = Convert.ToString(cbx_Cashier.SelectedItem.Col2);
            }
            catch (Exception ex)
            {
                user = string.Empty;
            }

            DataTable dt_InvoiceList = new DataTable();

            ////////////////////////////// By Customer ///////////////
            if (rdo_Customer.Checked)
            {
                String str_PONo = "";

                if (rdo_Cash.Checked == true)
                {
                    int_InvoiceType_Id = 1;
                }
                else if (rdo_Credit.Checked == true)
                {
                    int_InvoiceType_Id = 2;
                }
                else if (rdo_Consignment.Checked == true)
                {
                    int_InvoiceType_Id = 3;
                }

                dt_InvoiceList = obj_BLLInvoice.LoadPaidInvoiceTableForAllDataByFilter(dateTime_From, dateTime_To, int_Customer_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                //////////////////////


                ////////////// end of By Customer
            }
            /////////////////    By Customer Group
            else
            {
                String str_PONo = "";

                if (rdo_Cash.Checked == true)
                {
                    int_InvoiceType_Id = 1;
                }
                else if (rdo_Credit.Checked == true)
                {
                    int_InvoiceType_Id = 2;
                }
                else if (rdo_Consignment.Checked == true)
                {
                    int_InvoiceType_Id = 3;
                }

                dt_InvoiceList = obj_BLLInvoice.LoadPaidInvoiceTableForAllDataByFilterByCustomerGroup(dateTime_From, dateTime_To, int_CustomerGroup_Id, str_InvoiceNo, int_InvoiceType_Id, user, str_PONo);
                //////////////////////
            }

            bindReport(dt_InvoiceList);
        }
        private void bindInvoiceReport()
        {
            DataTable dt_Invoice;
            DataTable dt_InvoiceDetail;
            DataTable dt_InvoiceReturnDetail;

            DEInvoice invoice = new DEInvoice();

            invoice.Invoice_Id = invoice_Id;

            DEInvoiceDetail invoiceDetail = new DEInvoiceDetail();

            invoiceDetail.Invoice_Id = invoice_Id;

            DEInvoiceReturnDetail invoiceReturnDetail = new DEInvoiceReturnDetail();

            invoiceReturnDetail.Invoice_Id = invoice_Id;

            BLLInvoice             obj_BLLInvoice             = new BLLInvoice();
            BLLInvoiceDetail       obj_BLLInvoiceDetail       = new BLLInvoiceDetail();
            BLLInvoiceReturnDetail obj_BLLInvoiceReturnDetail = new BLLInvoiceReturnDetail();

            dt_Invoice             = obj_BLLInvoice.LoadInvoiceTableForAllDataByInvoice_Id(invoice);
            dt_InvoiceDetail       = obj_BLLInvoiceDetail.LoadInvoiceDetailTableForAllDataByInvoiceId(invoiceDetail);
            dt_InvoiceReturnDetail = obj_BLLInvoiceReturnDetail.LoadInvoiceReturnDetailTableForAllDataByInvoiceId(invoiceReturnDetail);

            NumberingTableForDataGridView(dt_InvoiceDetail);
            NumberingTableForDataGridView(dt_InvoiceReturnDetail);

            rptv_ConsignInvoiceReport.Clear();
            rptv_ConsignInvoiceReport.Reset();

            rptv_ConsignInvoiceReport.ProcessingMode = ProcessingMode.Local;

            LocalReport localReport = rptv_ConsignInvoiceReport.LocalReport;

            if (chb_SmallSize.Checked == false)
            {
                localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_ConsignInvoiceReport.rdlc";
            }
            else
            {
                localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_ConsignInvoiceA5Report.rdlc";
            }

            ReportDataSource ds_Invoice = new ReportDataSource();

            ds_Invoice.Name  = "DS_InvoiceReport_dt_Invoice";
            ds_Invoice.Value = dt_Invoice;

            ReportDataSource ds_InvoiceDetail = new ReportDataSource();

            ds_InvoiceDetail.Name  = "DS_InvoiceReport_dt_InvoiceDetail";
            ds_InvoiceDetail.Value = dt_InvoiceDetail;

            ReportDataSource ds_InvoiceReturnDetail = new ReportDataSource();

            ds_InvoiceReturnDetail.Name  = "DS_InvoiceReport_dt_InvoiceReturnDetail";
            ds_InvoiceReturnDetail.Value = dt_InvoiceReturnDetail;

            ReportParameter parTotal = new ReportParameter();

            parTotal.Name = "parTotal";

            ReportParameter parAdvance = new ReportParameter();

            parAdvance.Name = "parAdvance";

            ReportParameter parDiscount = new ReportParameter();

            parDiscount.Name = "parDiscount";

            ReportParameter parCommercialTax = new ReportParameter();

            parCommercialTax.Name = "parCommercialTax";

            ReportParameter parDeliveryDiscount = new ReportParameter();

            parDeliveryDiscount.Name = "parDeliveryDiscount";

            ReportParameter parReturnAmount = new ReportParameter();

            parReturnAmount.Name = "parReturnAmount";

            ReportParameter parDifferenceTotal = new ReportParameter();

            parDifferenceTotal.Name = "parDifferenceTotal";

            ReportParameter parGrandTotal = new ReportParameter();

            parGrandTotal.Name = "parGrandTotal";

            ReportParameter parInvoiceNo = new ReportParameter();

            parInvoiceNo.Name = "parInvoiceNo";

            ReportParameter parInvoiceDate = new ReportParameter();

            parInvoiceDate.Name = "parInvoiceDate";

            ReportParameter parCustomerName = new ReportParameter();

            parCustomerName.Name = "parCustomerName";

            ReportParameter parCustomerShop = new ReportParameter();

            parCustomerShop.Name = "parCustomerShop";

            ReportParameter parAddress = new ReportParameter();

            parAddress.Name = "parAddress";

            ReportParameter parPhone = new ReportParameter();

            parPhone.Name = "parPhone";

            ReportParameter parPONumber = new ReportParameter();

            parPONumber.Name = "parPONumber";

            ReportParameter parPromDesc = new ReportParameter();

            parPromDesc.Name = "parPromDesc";

            ReportParameter parIsPromotion = new ReportParameter();

            parIsPromotion.Name = "parIsPromotion";

            ReportParameter parPaymentStatus = new ReportParameter();

            parPaymentStatus.Name = "parPaymentStatus";

            ReportParameter parPaymentDate = new ReportParameter();

            parPaymentDate.Name = "parPaymentDate";

            ReportParameter parInvoiceDueDate = new ReportParameter();

            parInvoiceDueDate.Name = "parInvoiceDueDate";

            ReportParameter parShowReturn = new ReportParameter();

            parShowReturn.Name = "parShowReturn";

            ReportParameter parShow = new ReportParameter();

            parShow.Name = "parShowLetterHead";
            parShow.Values.Add(chb_ShowLetterHead.Checked.ToString());

            ReportParameter parShowFooter = new ReportParameter();

            parShowFooter.Name = "parShowLetterFooter";
            parShowFooter.Values.Add(chb_ShowLetterFooter.Checked.ToString());

            if (chb_Return.Checked == true)
            {
                parShowReturn.Values.Add("true");
            }
            else
            {
                parShowReturn.Values.Add("false");
            }

            Boolean bool_HasRow = obj_BLLInvoice.LoadInvoiceRow(invoice);

            if (true)
            {
                if (invoice.isPaid == true)
                {
                    parPaymentStatus.Values.Add("Paid on :");
                    parPaymentDate.Values.Add(invoice.PayDate.ToLongDateString());
                }
                else
                {
                    parPaymentStatus.Values.Add("No Paid :");
                    parPaymentDate.Values.Add("");
                }

                parInvoiceDueDate.Values.Add(invoice.Invoice_Due_Date.ToString());
                parTotal.Values.Add(invoice.Total.ToString());
                parAdvance.Values.Add(invoice.Advance.ToString());
                parDiscount.Values.Add(invoice.Discount.ToString());
                parCommercialTax.Values.Add(invoice.CommercialTax.ToString());
                parDeliveryDiscount.Values.Add(invoice.DeliveryDiscount.ToString());
                parGrandTotal.Values.Add(invoice.GrandTotal.ToString());

                parInvoiceNo.Values.Add(invoice.Invoice_No.ToString());
                parInvoiceDate.Values.Add(invoice.Invoice_Date.ToString());
                parCustomerName.Values.Add(invoice.Customer_Name);
                parCustomerShop.Values.Add(invoice.Customer_Description);
                parAddress.Values.Add(invoice.Address);
                parPhone.Values.Add(invoice.Phone);
                parPONumber.Values.Add(invoice.PONumber);
                parPromDesc.Values.Add(invoice.PromDesc);
                parIsPromotion.Values.Add(invoice.IsPromotion.ToString());

                Decimal dec_RetTotal  = 0;
                Decimal dec_DiffTotal = 0;

                for (int i = 0; i < dt_InvoiceReturnDetail.Rows.Count; i++)
                {
                    dec_RetTotal += Convert.ToDecimal(dt_InvoiceReturnDetail.Rows[i]["RAmount"].ToString());
                }

                if (dec_RetTotal != 0)
                {
                    dec_DiffTotal = invoice.GrandTotal - dec_RetTotal;
                }

                parReturnAmount.Values.Add(dec_RetTotal.ToString());
                parDifferenceTotal.Values.Add(dec_DiffTotal.ToString());
            }

            rptv_ConsignInvoiceReport.LocalReport.SetParameters(new ReportParameter[] { parTotal, parAdvance, parDiscount, parGrandTotal, parInvoiceNo, parInvoiceDate, parCustomerName, parCustomerShop, parAddress, parPhone, parInvoiceDueDate, parPaymentStatus, parPaymentDate, parShowReturn, parShow, parShowFooter, parPONumber, parPromDesc, parIsPromotion, parDeliveryDiscount, parCommercialTax, parReturnAmount, parDifferenceTotal }); // parPaymentStatus, parPaymentDate, parInvoiceDueDate });

            localReport.DataSources.Add(ds_InvoiceDetail);
            localReport.DataSources.Add(ds_Invoice);
            localReport.DataSources.Add(ds_InvoiceReturnDetail);

            rptv_ConsignInvoiceReport.RefreshReport();
        }
        private void search()
        {
            if (false) //(cbx_Customer.Text.Trim().Length == 0 || cbx_Customer.SelectedValue == null)
            {
                ErrorProvider.SetError(cbx_Customer, "Please Select Customer");
                string str_error = ErrorProvider.GetError(cbx_Customer);
                MessageBox.Show(str_error);

                ErrorProvider.Clear();
            }
            else
            {
                BLLInvoice obj_BLLInvoice = new BLLInvoice();

                DECustomer customer = new DECustomer();
                DEInvoice  invoice  = new DEInvoice();

                DECatagory category = new DECatagory();

                DateTime dateTime_From = Convert.ToDateTime(dtp_InvoiceDateFrom.Value);
                DateTime dateTime_To   = Convert.ToDateTime(dtp_InvoiceDateTo.Value.Date.AddHours(23.9));

                try
                {
                    customer.Catagory_Id          = Convert.ToInt32(cbx_CustomerGroup.SelectedItem.Col3);
                    customer.Catagory_Description = cbx_CustomerGroup.SelectedText;
                }
                catch (Exception ex)
                {
                    customer.Catagory_Id          = 0;
                    customer.Customer_Description = "";
                }

                try
                {
                    customer.Customer_Id = Convert.ToInt32(cbx_Customer.SelectedItem.Col4);
                }
                catch (Exception ex)
                {
                    customer.Customer_Id = 0;
                }

                try
                {
                    category.Catagory_Id = Convert.ToInt32(cbx_Category.SelectedItem.Col3);
                }
                catch (Exception ex)
                {
                    category.Catagory_Id = 0;
                }

                invoice.Customer_Id           = customer.Customer_Id;
                customer.Customer_Description = cbx_Customer.Text;
                customer.Address = txt_Address.Text;
                customer.Phone   = txt_PhoneNo.Text;

                DataTable dt_Sale   = new DataTable();
                DataTable dt_Return = new DataTable();

                if (rdo_Customer.Checked)
                {
                    dt_Sale   = obj_BLLInvoice.LoadInvoiceDetailTableForAllDataByInvoiceDateCustomerId(invoice.Customer_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                    dt_Return = obj_BLLInvoice.LoadProductReturnSummaryTableForAllDataByInvoiceDateCustomerId(invoice.Customer_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                }
                else
                {
                    dt_Sale   = obj_BLLInvoice.LoadInvoiceDetailTableForAllDataByInvoiceDateCustomerGroupId(customer.Catagory_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                    dt_Return = obj_BLLInvoice.LoadProductReturnSummaryTableForAllDataByInvoiceDateCustomerId(customer.Catagory_Id, dateTime_From, dateTime_To, category.Catagory_Id);
                }

                if (rdo_Sale.Checked == true)
                {
                    bindSaleReport(customer, dt_Sale);
                }
                else
                {
                    bindReturnReport(customer, dt_Return);
                }
            }
        }
Exemple #5
0
        private void bindCashInvoiceReport()
        {
            DataTable dt_Invoice;
            DataTable dt_InvoiceDetail;

            DEInvoice invoice = new DEInvoice();

            invoice.Invoice_Id = invoice_Id;

            DEInvoiceDetail invoiceDetail = new DEInvoiceDetail();

            invoiceDetail.Invoice_Id = invoice_Id;

            BLLInvoice       obj_BLLInvoice       = new BLLInvoice();
            BLLInvoiceDetail obj_BLLInvoiceDetail = new BLLInvoiceDetail();

            dt_Invoice       = obj_BLLInvoice.LoadInvoiceTableForAllDataByInvoice_Id(invoice);
            dt_InvoiceDetail = obj_BLLInvoiceDetail.LoadInvoiceDetailTableForAllDataByInvoiceId(invoiceDetail);

            NumberingTableForDataGridView(dt_InvoiceDetail);

            rptv_CashInvoiceReport.Clear();
            rptv_CashInvoiceReport.Reset();

            rptv_CashInvoiceReport.ProcessingMode = ProcessingMode.Local;

            LocalReport localReport = rptv_CashInvoiceReport.LocalReport;

            if (chb_SmallSize.Checked == false)
            {
                localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_CashInvoiceReport.rdlc";
            }
            else
            {
                localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_CashInvoiceA5Report.rdlc";
            }

            ReportDataSource ds_Invoice = new ReportDataSource();

            ds_Invoice.Name  = "DS_InvoiceReport_dt_Invoice";
            ds_Invoice.Value = dt_Invoice;

            ReportDataSource ds_InvoiceDetail = new ReportDataSource();

            ds_InvoiceDetail.Name  = "DS_InvoiceReport_dt_InvoiceDetail";
            ds_InvoiceDetail.Value = dt_InvoiceDetail;

            ReportParameter parTotal = new ReportParameter();

            parTotal.Name = "parTotal";

            ReportParameter parAdvance = new ReportParameter();

            parAdvance.Name = "parAdvance";

            ReportParameter parDiscount = new ReportParameter();

            parDiscount.Name = "parDiscount";

            ReportParameter parCommercialTax = new ReportParameter();

            parCommercialTax.Name = "parCommercialTax";

            ReportParameter parDeliveryDiscount = new ReportParameter();

            parDeliveryDiscount.Name = "parDeliveryDiscount";

            ReportParameter parGrandTotal = new ReportParameter();

            parGrandTotal.Name = "parGrandTotal";

            ReportParameter parInvoiceNo = new ReportParameter();

            parInvoiceNo.Name = "parInvoiceNo";

            ReportParameter parInvoiceDate = new ReportParameter();

            parInvoiceDate.Name = "parInvoiceDate";

            ReportParameter parCustomerName = new ReportParameter();

            parCustomerName.Name = "parCustomerName";

            ReportParameter parCustomerShop = new ReportParameter();

            parCustomerShop.Name = "parCustomerShop";

            ReportParameter parAddress = new ReportParameter();

            parAddress.Name = "parAddress";

            ReportParameter parPhone = new ReportParameter();

            parPhone.Name = "parPhone";

            ReportParameter parPONumber = new ReportParameter();

            parPONumber.Name = "parPONumber";

            ReportParameter parPromDesc = new ReportParameter();

            parPromDesc.Name = "parPromDesc";

            ReportParameter parIsPromotion = new ReportParameter();

            parIsPromotion.Name = "parIsPromotion";

            ReportParameter parShow = new ReportParameter();

            parShow.Name = "parShowLetterHead";
            parShow.Values.Add(chb_ShowLetterHead.Checked.ToString());

            ReportParameter parShowFooter = new ReportParameter();

            parShowFooter.Name = "parShowLetterFooter";
            parShowFooter.Values.Add(chb_ShowLetterFooter.Checked.ToString());

            Boolean bool_HasRow = obj_BLLInvoice.LoadInvoiceRow(invoice);

            if (true)
            {
                parTotal.Values.Add(invoice.Total.ToString());
                parAdvance.Values.Add(invoice.Advance.ToString());
                parDiscount.Values.Add(invoice.Discount.ToString());
                parCommercialTax.Values.Add(invoice.CommercialTax.ToString());
                parDeliveryDiscount.Values.Add(invoice.DeliveryDiscount.ToString());
                parGrandTotal.Values.Add(invoice.GrandTotal.ToString());

                parInvoiceNo.Values.Add(invoice.Invoice_No.ToString());
                parInvoiceDate.Values.Add(invoice.Invoice_Date.ToString());
                parCustomerName.Values.Add(invoice.Customer_Name);
                parCustomerShop.Values.Add(invoice.Customer_Description);
                parAddress.Values.Add(invoice.Address);
                parPhone.Values.Add(invoice.Phone);
                parPONumber.Values.Add(invoice.PONumber);
                parPromDesc.Values.Add(invoice.PromDesc);
                parIsPromotion.Values.Add(invoice.IsPromotion.ToString());
            }


            rptv_CashInvoiceReport.LocalReport.SetParameters(new ReportParameter[] { parTotal, parAdvance, parDiscount, parGrandTotal, parInvoiceNo, parInvoiceDate, parCustomerName, parCustomerShop, parAddress, parPhone, parShow, parShowFooter, parPONumber, parPromDesc, parIsPromotion, parDeliveryDiscount, parCommercialTax });

            localReport.DataSources.Add(ds_InvoiceDetail);
            localReport.DataSources.Add(ds_Invoice);

            rptv_CashInvoiceReport.RefreshReport();
        }