protected void Button1_Click(object sender, EventArgs e) { try { bl.vch_id = Convert.ToInt32(DropDownList1.SelectedValue.ToString()); bl.vch_nm = DropDownList1.SelectedItem.Text; bl.inv_no = txt_inv.Text; bl.inv_date = txt_inv_dt.Text; 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.rn_no = txt_dc_no.Text; bl.l_r_no = txt_lr_no.Text; bl.p_o_no = txt_pr_no.Text; bl.rn_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 = ""; } TextBox txt_total_qty = (TextBox)grid_array.FooterRow.FindControl("txt_tt"); TextBox txt_total_net = (TextBox)grid_array.FooterRow.FindControl("txt_ttt"); bl.total_qty = txt_total_qty.Text; bl.total = txt_total_net.Text; bl.dic = TextBox9.Text; bl.net_amount = txt_net_amt.Text; bl.credit_amt = txt_net_amt.Text; dl.insert_puch_inv(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) { int pch = Convert.ToInt32(dl.get__puch_inv_no(bl)); bl.puch_id = Convert.ToString(pch); 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_puch_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) { int pch = Convert.ToInt32(dl.get__puch_inv_no(bl)); bl.puch_id = Convert.ToString(pch); 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_puch_extra(bl); } else { break; } } stockmange(); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Invoice Created successfully'); window.location='puch_genrate.aspx';", true); } catch { } }