Esempio n. 1
0
        public void setformstockout()
        {
            //this.Enabled = false;
            string[] strfinalarray = new string[lvstockout.Items.Count];
            if (lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[1].Text == "S")
            {
                strfinalarray = new string[5] {
                    "S", "D", "Sale", "S", ""
                };
            }
            else if (lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[1].Text == "P")
            {
                strfinalarray = new string[5] {
                    "P", "C", "Purchase", "P", ""
                };
            }
            else if (lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[1].Text == "SC")
            {
                strfinalarray = new string[5] {
                    "SC", "D", "Sale Challan", "SC", ""
                };
            }
            else if (lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[1].Text == "PR")
            {
                strfinalarray = new string[5] {
                    "PR", "D", "PurchaseReturn", "PR", ""
                };
            }
            String           str = lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[2].Text;
            DataTable        dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
            DefaultSale      bd  = new DefaultSale(this, master, tabControl, strfinalarray);
            DefaultSaleOrder bd1 = new DefaultSaleOrder(this, master, tabControl, strfinalarray);

            //  Sale p = new Sale(this, master, tabControl);
            if (dt1.Rows[0]["formname"].ToString() == bd.Text)
            {
                bd.updatemode(str, lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[2].Text, Convert.ToInt32(lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[10].Text), strfinalarray);
                master.AddNewTab(bd);
            }
            else if (dt1.Rows[0]["formname"].ToString() == bd1.Text)
            {
                bd1.updatemode(str, lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[2].Text, Convert.ToInt32(lvstockout.Items[lvstockout.FocusedItem.Index].SubItems[10].Text), strfinalarray);
                master.AddNewTab(bd1);
            }
        }
        public void open()
        {
            if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Sale")
            {
                string[] strfinalarray = new string[5] {
                    "S", "D", "Sale", "", ""
                };
                string billno = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text.Remove(0, 9);

                String      str = LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text;
                DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                DefaultSale bd  = new DefaultSale(this, master, tabControl, strfinalarray);
                //   Sale p = new Sale(this, master, tabControl);
                if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                {
                    bd.updatemode(str, billno, 1, strfinalarray);
                    //bd.MdiParent = this.MdiParent;
                    //bd.StartPosition = FormStartPosition.CenterScreen;
                    //bd.Show();
                    master.AddNewTab(bd);
                }
                //else if (dt1.Rows[0]["formname"].ToString() == p.Text)
                //{
                //    p.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1);
                //    //p.MdiParent = this.MdiParent;
                //    //p.StartPosition = FormStartPosition.CenterScreen;
                //    //p.Show();
                //    master.AddNewTab(p);
                //}



                bd.Show();
            }
            else if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Sale Return")
            {
                string[] strfinalarray = new string[5] {
                    "SR", "C", "Sale Return", "SR", ""
                };
                string billno = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text.Remove(0, 9);

                String      str = LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text;
                DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                DefaultSale bd  = new DefaultSale(this, master, tabControl, strfinalarray);
                //    Sale p = new Sale(this, master, tabControl);
                if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                {
                    bd.updatemode(str, billno, 1, strfinalarray);
                    //bd.MdiParent = this.MdiParent;
                    //bd.StartPosition = FormStartPosition.CenterScreen;
                    //bd.Show();
                    master.AddNewTab(bd);
                }
                //else if (dt1.Rows[0]["formname"].ToString() == p.Text)
                //{
                //    p.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1);
                //    //p.MdiParent = this.MdiParent;
                //    //p.StartPosition = FormStartPosition.CenterScreen;
                //    //p.Show();
                //    master.AddNewTab(p);
                //}



                //  bd.Show();
            }
            else if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Purchase")
            {
                string[] strfinalarray = new string[5] {
                    "P", "C", "Purchase", "", ""
                };
                string    billno = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text.Remove(0, 9);
                String    str    = LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text;
                DataTable dt1    = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                //DefaultPurchase frm = new DefaultPurchase(this);
                DefaultSale bd = new DefaultSale(this, master, tabControl, strfinalarray);
                //   Purchase p = new Purchase(this, master, tabControl);
                if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                {
                    bd.updatemode(str, billno, 1, strfinalarray);
                    //bd.MdiParent = this.MdiParent;
                    //bd.StartPosition = FormStartPosition.CenterScreen;
                    //bd.Show();
                    master.AddNewTab(bd);
                }
                //else if (dt1.Rows[0]["formname"].ToString() == p.Text)
                //{
                //    p.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1);
                //    //p.MdiParent = this.MdiParent;
                //    //p.StartPosition = FormStartPosition.CenterScreen;
                //    //p.Show();
                //    master.AddNewTab(p);
                //}

                //    DefaultPurchase bd = new DefaultPurchase(this);

                //  bd.Show();
            }
            else if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Purchase Return")
            {
                string[] strfinalarray = new string[5] {
                    "PR", "D", "Purchase Return", "PR", ""
                };
                string    billno = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text.Remove(0, 9);
                String    str    = LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text;
                DataTable dt1    = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                //DefaultPurchase frm = new DefaultPurchase(this);
                DefaultSale bd = new DefaultSale(this, master, tabControl, strfinalarray);
                //Purchase p = new Purchase(this, master, tabControl);
                if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                {
                    bd.updatemode(str, billno, 1, strfinalarray);
                    //bd.MdiParent = this.MdiParent;
                    //bd.StartPosition = FormStartPosition.CenterScreen;
                    //bd.Show();
                    master.AddNewTab(bd);
                }
                //else if (dt1.Rows[0]["formname"].ToString() == p.Text)
                //{
                //    p.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1);
                //    //p.MdiParent = this.MdiParent;
                //    //p.StartPosition = FormStartPosition.CenterScreen;
                //    //p.Show();
                //    master.AddNewTab(p);
                //}
            }
            else if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Rect")
            {
                String str = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text;

                QReceipt bd = new QReceipt();
                bd.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1, LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text);
                bd.Show();
            }
            else if (LVledger.Items[LVledger.FocusedItem.Index].SubItems[1].Text == "Pmnt")
            {
                String str = LVledger.Items[LVledger.FocusedItem.Index].SubItems[2].Text;

                QPayment bd = new QPayment();
                bd.updatemode(str, mouseclickid.Rows[LVledger.FocusedItem.Index][1].ToString(), 1, LVledger.Items[LVledger.FocusedItem.Index].SubItems[0].Text);
                bd.Show();
            }
        }
 private void BtnViewReport_Click(object sender, EventArgs e)
 {
     try
     {
         // strfinalarray = new string[LVDayBook.CheckedItems.Count];
         for (int i = 0; i < LVDayBook.Items.Count; i++)
         {
             if (Convert.ToBoolean(LVDayBook.Items[i].Checked) == true)
             {
                 if (LVDayBook.Items[i].SubItems[1].Text == "Sale")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "S", "D", "Sale", "S", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt,b.ClientID from billmaster b left join Billchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt,b.clientID order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String      str = dt.Rows[j]["billno"].ToString();
                             DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSale bd  = new DefaultSale(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), Convert.ToInt32(dt.Rows[j]["ClientID"].ToString()), strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Sale Return")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "SR", "C", "SaleReturn", "SR", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from billmaster b left join Billchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String      str = dt.Rows[j]["billno"].ToString();
                             DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSale bd  = new DefaultSale(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Sale Order")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "SO", "D", "Sale Order", "SO", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from SaleOrderMaster b left join SaleOrderchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String           str = dt.Rows[j]["billno"].ToString();
                             DataTable        dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSaleOrder bd  = new DefaultSaleOrder(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Sale Challan")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "SC", "D", "Sale Challan", "SC", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from SaleOrderMaster b left join SaleOrderchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String           str = dt.Rows[j]["billno"].ToString();
                             DataTable        dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSaleOrder bd  = new DefaultSaleOrder(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Purchase")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "P", "C", "Purchase", "P", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt,b.clientID from billmaster b left join Billchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt,b.clientID order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String      str = dt.Rows[j]["billno"].ToString();
                             DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSale bd  = new DefaultSale(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), Convert.ToInt32(dt.Rows[j]["ClientID"].ToString()), strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Purchase Return")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "PR", "D", "PurchaseReturn", "PR", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from billmaster b left join Billchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String      str = dt.Rows[j]["billno"].ToString();
                             DataTable   dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSale bd  = new DefaultSale(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Purchase Order")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "PO", "C", "Purchase Order", "PO", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from SaleOrderMaster b left join SaleOrderchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String           str = dt.Rows[j]["billno"].ToString();
                             DataTable        dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSaleOrder bd  = new DefaultSaleOrder(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
                 else if (LVDayBook.Items[i].SubItems[1].Text == "Purchase Challan")
                 {
                     rewritedata = "True";
                     string[] strfinalarray = new string[5] {
                         "PC", "C", "Purchase Challan", "PC", ""
                     };
                     DataTable dt = conn.getdataset("select b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,sum(b.totaltax + isnull(bc.sgst,0)+isnull(bc.cgst,0)+isnull(bc.igst,0)) as totaltax,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt from SaleOrderMaster b left join SaleOrderchargesmaster bc on bc.billno=b.billno and bc.isactive=1 inner join clientmaster c on c.clientid=b.clientid  where c.isactive=1 and b.isactive=1 and b.BillType='" + strfinalarray[0] + "' and b.Bill_Date>='" + Convert.ToDateTime(DTPFrom.Text).ToString(Master.dateformate) + "' and b.Bill_Date<='" + Convert.ToDateTime(DTPTo.Text).ToString(Master.dateformate) + "'group by b.billno, b.bill_date, b.po_no, c.accountname,b.refno,b.totalcharges,b.totalbasic,b.totalnet,c.GstNo,b.cgatamt,b.sgstamt order by b.bill_date asc");
                     for (int j = 0; j < dt.Rows.Count; j++)
                     {
                         try
                         {
                             String           str = dt.Rows[j]["billno"].ToString();
                             DataTable        dt1 = conn.getdataset("select * from FormFormat where isactive=1 and type='" + strfinalarray[0] + "' and setdefault=1");
                             DefaultSaleOrder bd  = new DefaultSaleOrder(master, tabControl, strfinalarray);
                             //  Sale p = new Sale(this, master, tabControl);
                             if (dt1.Rows[0]["formname"].ToString() == bd.Text)
                             {
                                 bd.updatemode(str, dt.Rows[j]["billno"].ToString(), 1, strfinalarray);
                                 master.AddNewTab(bd);
                                 bd.BtnPayment_Click(sender, e);
                                 master.RemoveCurrentTab();
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }