Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            bl.comp_nm = txt_comp_nm.Text;
            int cmp = Convert.ToInt32(dl.slelct_cust_id_bill(bl));
            bl.cust_id    = cmp;
            bl.brock_name = txt_brok_nm.Text;
            int bro = Convert.ToInt32(dl.slelct_brock_id_bill(bl));
            bl.brock_id = bro;
            bl.trp_naem = txt_trp_nm.Text;
            int trp_id = Convert.ToInt32(dl.slelct_transport_id_bill(bl));
            bl.trp_id   = trp_id;
            bl.dc_no    = txt_dc_no.Text;
            bl.l_r_no   = txt_lr_no.Text;
            bl.p_o_no   = txt_pr_no.Text;
            bl.dc_date  = txt_dc_date.Text;
            bl.l_r_date = txt_lr_date.Text;
            bl.p_o_date = txt_po_date.Text;
            if (txt_tax4.Text != string.Empty)
            {
                bl.tax_4 = txt_tax4.Text;
                bl.vat_1 = txt_vat1.Text;
            }
            else
            {
                bl.tax_4 = "";
                bl.vat_1 = "";
            }
            if (txt_txt12.Text != string.Empty)
            {
                bl.tax_12 = txt_txt12.Text;
                bl.vat_2  = txt_vat2.Text;
            }
            else
            {
                bl.tax_12 = "";
                bl.vat_2  = "";
            }
            if (txt_tax2.Text != string.Empty)
            {
                bl.cst_2 = txt_tax2.Text;
            }
            else
            {
                bl.cst_2 = "";
            }
            if (TextBox9.Text != string.Empty)
            {
                bl.disc = TextBox9.Text;
            }
            else
            {
                bl.disc = "";
            }
            bl.net_amount = txt_net_amt.Text;
            dl.insert_dc(bl);
            DataSet   ds = new DataSet();
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                TextBox t1 = (TextBox)grid_array.Rows[i].FindControl("TextBox1");
                TextBox t2 = (TextBox)grid_array.Rows[i].FindControl("TextBox2");
                TextBox t3 = (TextBox)grid_array.Rows[i].FindControl("TextBox3");
                TextBox t4 = (TextBox)grid_array.Rows[i].FindControl("TextBox4");
                TextBox t5 = (TextBox)grid_array.Rows[i].FindControl("TextBox5");
                TextBox t6 = (TextBox)grid_array.Rows[i].FindControl("TextBox6");
                TextBox t7 = (TextBox)grid_array.Rows[i].FindControl("TextBox7");
                TextBox t8 = (TextBox)grid_array.Rows[i].FindControl("TextBox8");

                if (t1.Text != string.Empty)
                {
                    bl.dc_no     = txt_dc_no.Text;
                    bl.item_name = t1.Text;
                    int id = Convert.ToInt32(dl.slelct_item_id_bill(bl));
                    bl.item_id = id;
                    bl.dcsr    = t2.Text;
                    bl.qty     = t3.Text;
                    bl.rate    = t4.Text;
                    bl.per     = t5.Text;
                    bl.disc    = t7.Text;
                    bl.tax     = t8.Text;
                    bl.amount  = t6.Text;
                    dl.insert_dc_item(bl);
                }
                else
                {
                    break;
                }
            }
            DataSet   ds2 = new DataSet();
            DataTable dt2 = (DataTable)ViewState["CurrentTable2"];
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                TextBox t1 = (TextBox)grd_add.Rows[i].FindControl("txt_lg");
                TextBox t2 = (TextBox)grd_add.Rows[i].FindControl("txt_amt");


                if (t1.Text != string.Empty)
                {
                    bl.dc_no = txt_dc_no.Text;
                    bl.ld_nm = t1.Text;
                    int id = Convert.ToInt32(dl.slelct_ld_id_bill(bl));
                    bl.ld_id    = id;
                    bl.extra_rs = t2.Text;
                    dl.insert_dc_extra(bl);
                }
                else
                {
                    break;
                }
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('DC Created successfully'); window.location='dc.aspx';", true);
        }
        catch
        {
        }
    }