protected void btnsubmit_Click(object sender, EventArgs e)
    {
        Handler hdnpartycode=new Handler();
        DataTable dtpartycode=hdnpartycode.GetTable("SELECT SRNO FROM PARTYMASTER PM WHERE PARTYCODE='"+txtpartycode.Text.Trim().ToString()+"'");
        if (dtpartycode.Rows.Count == 0)
        {
            DataTable dtmax = new DataTable();
            partymaster objpartymaster = new partymaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            objpartymaster.partymaster_SRNO = -1;
            objpartymaster.partymaster_PARTYNAME = txtpartyname.Text.Trim().ToString();
            objpartymaster.partymaster_PARTYCODE = txtpartycode.Text.Trim().ToString();
            objpartymaster.partymaster_PARTYTYPE = ddlpartytype.SelectedItem.Text.ToString();
            objpartymaster.partymaster_PARTYTYPECODE = General.Parse<int>(ddlpartytype.SelectedValue.ToString());
            if (rdaddonyes.Checked == true)
            {
                objpartymaster.partymaster_PARTYADDON = 1;
            }
            else
            {
                objpartymaster.partymaster_PARTYADDON = 0;
            }
            objpartymaster.partymaster_PHONENO = txtphone.Text.Trim().ToString();
            if (txtfax.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_FAX = txtfax.Text.Trim().ToString();
            }
            if (txtemail.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_EMAIL = txtemail.Text.Trim().ToString();
            }
            if (txtwebsite.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_WEBSITE = txtwebsite.Text.Trim().ToString();
            }
            if (txtpanno.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_PANNO = txtpanno.Text.Trim().ToString();
            }
            if (txtcstno.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_CSTNO = txtcstno.Text.Trim().ToString();
            }
            if (txtvatno.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_VATNO = txtvatno.Text.Trim().ToString();
            }
            if (txtservicetaxno.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_SERVICETAXNO = txtservicetaxno.Text.Trim().ToString();
            }
            if (txtexciseno.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_EXCISENO = txtexciseno.Text.Trim().ToString();
            }
            if (txtexciserange.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_EXCISERANGE = txtexciserange.Text.Trim().ToString();
            }
            if (txtexcisedivision.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_EXCISEDIVISION = txtexcisedivision.Text.Trim().ToString();
            }
            if (txtexcisecollectrate.Text.Trim().ToString() != string.Empty)
            {
                objpartymaster.partymaster_EXCISECOLLECTRATE = txtexcisecollectrate.Text.Trim().ToString();
            }
            if (objpartymaster.Insert(true, "partymaster"))
            {
                string sqlmax = "SELECT MAX(SRNO) AS SRNO FROM partymaster WHERE PARTYNAME='" + txtpartyname.Text.Trim().ToString() + "' AND PARTYCODE='" + txtpartycode.Text.Trim().ToString() + "' ";
                Handler hdnmax = new Handler();
                dtmax = hdnmax.GetTable(sqlmax);
                if (dtmax.Rows.Count > 0)
                {
                    personaltable objpersonal1 = new personaltable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objpersonal1.personaltable_RELATIONSHIPID = -1;
                    objpersonal1.personaltable_FIRSTNAME = txtpartyname.Text.Trim().ToString();
                    objpersonal1.personaltable_BRANCHID = General.Parse<int>(Session["branchid"].ToString());
                    Handler branch = new Handler();
                    DataTable dtbranch = branch.GetTable("select BRANCHNAME from branchmaster where branchid=" + Session["branchid"].ToString());
                    objpersonal1.personaltable_BRANCHNAME = dtbranch.Rows[0][0].ToString().Trim();
                    if (objpersonal1.Insert(true, "personaltable"))
                    {
                        string sql = "SELECT MAX(PR.RELATIONSHIPID) AS RELATIONSHIPID FROM personaltable PR WHERE PR.BRANCHID=1 AND PR.FIRSTNAME='" + txtpartyname.Text.Trim().ToString() + "'";
                        Handler hdn = new Handler();
                        DataTable dt = hdn.GetTable(sql);
                        personalrelation objpersonalrelation = new personalrelation(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                        objpersonalrelation.personalrelation_SRNO = -1;
                        objpersonalrelation.personalrelation_RELATIONSHIPID = General.Parse<int>(dt.Rows[0][0].ToString());
                        objpersonalrelation.personalrelation_ASSOSIATEDFEILD = "MAIN ACCOOUNT";
                        objpersonalrelation.personalrelation_ASSOSIATEDBRANCH = General.Parse<int>(Session["branchid"].ToString());
                        objpersonalrelation.personalrelation_GROUPID = 100;
                        objpersonalrelation.personalrelation_STATUS = 0;
                        if (objpersonalrelation.Insert(true, "personalrelation"))
                        {
                        }
                    }

                    partyaddressmaster objpartyaddressmaster = new partyaddressmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objpartyaddressmaster.partyaddressmaster_SRNO = -1;
                    objpartyaddressmaster.partyaddressmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                    objpartyaddressmaster.partyaddressmaster_ADDRESSTYPE = 1;
                    objpartyaddressmaster.partyaddressmaster_ADDRESS = txtaddress.Text.Trim().ToString();
                    objpartyaddressmaster.partyaddressmaster_CITYID = General.Parse<int>(ddlcity.SelectedValue.ToString()); ;
                    objpartyaddressmaster.partyaddressmaster_CITYNAME = ddlcity.SelectedItem.Text.Trim().ToString(); ;
                    objpartyaddressmaster.partyaddressmaster_STATEID = General.Parse<int>(ddlstate.SelectedValue.ToString()); ;
                    objpartyaddressmaster.partyaddressmaster_STATENAME = ddlstate.SelectedItem.Text.Trim().ToString(); ;
                    objpartyaddressmaster.partyaddressmaster_PINCODE = txtpin.Text.Trim().ToString(); ;
                    objpartyaddressmaster.partyaddressmaster_STATUS = 0;
                    if (objpartyaddressmaster.Insert(true, "partyaddressmaster"))
                    {
                    }
                    partyaddressmaster objpartyworkaddressmaster = new partyaddressmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objpartyworkaddressmaster.partyaddressmaster_SRNO = -1;
                    objpartyworkaddressmaster.partyaddressmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                    objpartyworkaddressmaster.partyaddressmaster_ADDRESSTYPE = 2;
                    objpartyworkaddressmaster.partyaddressmaster_ADDRESS = txtworkaddress.Text.Trim().ToString();
                    objpartyworkaddressmaster.partyaddressmaster_CITYID = General.Parse<int>(ddlworkcity.SelectedValue.ToString()); ;
                    objpartyworkaddressmaster.partyaddressmaster_CITYNAME = ddlworkcity.SelectedItem.Text.Trim().ToString(); ;
                    objpartyworkaddressmaster.partyaddressmaster_STATEID = General.Parse<int>(ddlworkstate.SelectedValue.ToString()); ;
                    objpartyworkaddressmaster.partyaddressmaster_STATENAME = ddlworkstate.SelectedItem.Text.Trim().ToString(); ;
                    objpartyworkaddressmaster.partyaddressmaster_PINCODE = txtworkpin.Text.Trim().ToString(); ;
                    objpartyworkaddressmaster.partyaddressmaster_STATUS = 0;
                    if (objpartyworkaddressmaster.Insert(true, "partyaddressmaster"))
                    {
                    }


                    if (dtmax.Rows.Count > 0 && memberrepeater.Items.Count > 0)
                    {
                        for (int i = 0; i < memberrepeater.Items.Count; i++)
                        {

                            TextBox name = (TextBox)memberrepeater.Items[i].FindControl("txtpersonname");
                            DropDownList department = (DropDownList)memberrepeater.Items[i].FindControl("ddldepartment");
                            DropDownList designation = (DropDownList)memberrepeater.Items[i].FindControl("ddldesignation");
                            TextBox phone = (TextBox)memberrepeater.Items[i].FindControl("txtperphone");
                            TextBox email = (TextBox)memberrepeater.Items[i].FindControl("txtperemailid");
                            TextBox mobile = (TextBox)memberrepeater.Items[i].FindControl("txtpermobile");

                            personalmaster objpersonal = new personalmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                            objpersonal.personalmaster_SRNO = -1;
                            objpersonal.personalmaster_PERSONNAME = name.Text.ToString().Trim();
                            objpersonal.personalmaster_DEPARTMENT = department.SelectedItem.Text.Trim().ToString();
                            objpersonal.personalmaster_DESIGNATION = designation.SelectedItem.Text.Trim().ToString();
                            objpersonal.personalmaster_EMAILID = email.Text.ToString().Trim();
                            objpersonal.personalmaster_PHONENO = phone.Text.ToString().Trim();
                            objpersonal.personalmaster_MOBILE = mobile.Text.ToString().Trim();
                            objpersonal.personalmaster_PERSONRELATIONID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                            objpersonal.personalmaster_PERSONTYPE = "PARTY";
                            if (objpersonal.Insert(true, "personalmaster"))
                            {
                            }


                        }
                    }
                    string sqltax = "SELECT SRNO AS TAXID,TAXNAME,TAXVALUE,TAXUNIT FROM taxmaster WHERE STATUS=0";
                    Handler hdntax = new Handler();
                    DataTable dttax = hdntax.GetTable(sqltax);

                    for (int k = 0; k < dttax.Rows.Count; k++)
                    {
                        if (dttax.Rows[k]["TAXNAME"].ToString().Trim() == "VAT" && rdvat.Checked == true)
                        {
                            partytaxmaster objpartytax = new partytaxmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                            objpartytax.partytaxmaster_SRNO = -1;
                            objpartytax.partytaxmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                            objpartytax.partytaxmaster_TAXID = General.Parse<int>(dttax.Rows[k]["TAXID"].ToString());
                            objpartytax.partytaxmaster_TAXNAME = dttax.Rows[k]["TAXNAME"].ToString();
                            objpartytax.partytaxmaster_TAXVALUE = General.Parse<double>(dttax.Rows[k]["TAXVALUE"].ToString());
                            objpartytax.partytaxmaster_TAXUNIT = dttax.Rows[k]["TAXUNIT"].ToString();
                            if (objpartytax.Insert(true, "partytaxmaster"))
                            {
                            }
                        }
                        if (dttax.Rows[k]["TAXNAME"].ToString().Trim() == "CST" && rdexcise.Checked == true)
                        {
                            partytaxmaster objpartytax = new partytaxmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                            objpartytax.partytaxmaster_SRNO = -1;
                            objpartytax.partytaxmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                            objpartytax.partytaxmaster_TAXID = General.Parse<int>(dttax.Rows[k]["TAXID"].ToString());
                            objpartytax.partytaxmaster_TAXNAME = dttax.Rows[k]["TAXNAME"].ToString();
                            objpartytax.partytaxmaster_TAXVALUE = General.Parse<double>(dttax.Rows[k]["TAXVALUE"].ToString());
                            objpartytax.partytaxmaster_TAXUNIT = dttax.Rows[k]["TAXUNIT"].ToString();
                            if (objpartytax.Insert(true, "partytaxmaster"))
                            {
                            }
                        }
                        if (dttax.Rows[k]["TAXNAME"].ToString().Trim() == "SERVICE TAX" && rdserviceapplicable.Checked == true)
                        {
                            partytaxmaster objpartytax = new partytaxmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                            objpartytax.partytaxmaster_SRNO = -1;
                            objpartytax.partytaxmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                            objpartytax.partytaxmaster_TAXID = General.Parse<int>(dttax.Rows[k]["TAXID"].ToString());
                            objpartytax.partytaxmaster_TAXNAME = dttax.Rows[k]["TAXNAME"].ToString();
                            objpartytax.partytaxmaster_TAXVALUE = General.Parse<double>(dttax.Rows[k]["TAXVALUE"].ToString());
                            objpartytax.partytaxmaster_TAXUNIT = dttax.Rows[k]["TAXUNIT"].ToString();
                            if (objpartytax.Insert(true, "partytaxmaster"))
                            {
                            }
                        }
                        if (dttax.Rows[k]["TAXNAME"].ToString().Trim() == "EXCISE" && rdexciseapplicable.Checked == true)
                        {
                            partytaxmaster objpartytax = new partytaxmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                            objpartytax.partytaxmaster_SRNO = -1;
                            objpartytax.partytaxmaster_PARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                            objpartytax.partytaxmaster_TAXID = General.Parse<int>(dttax.Rows[k]["TAXID"].ToString());
                            objpartytax.partytaxmaster_TAXNAME = dttax.Rows[k]["TAXNAME"].ToString();
                            objpartytax.partytaxmaster_TAXVALUE = General.Parse<double>(dttax.Rows[k]["TAXVALUE"].ToString());
                            objpartytax.partytaxmaster_TAXUNIT = dttax.Rows[k]["TAXUNIT"].ToString();
                            if (objpartytax.Insert(true, "partytaxmaster"))
                            {
                            }
                        }
                    }
                }
                Response.Redirect("partylist.aspx?ID=2");

            }
            else
            {
                MessageBox("Party Code Already Present");
            }
       
    }
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        int check = 0;
        personaltable objpersonal = new personaltable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
        objpersonal.personaltable_RELATIONSHIPID = -1;
        objpersonal.personaltable_FIRSTNAME = txtledgername.Text.Trim().ToString();
        objpersonal.personaltable_BRANCHID = General.Parse<int>(Session["branchid"].ToString());
        objpersonal.personaltable_BRANCHNAME = Session["branchname"].ToString();
        if (objpersonal.Insert(true, "personaltable"))
        {
            string sql = "SELECT MAX(PR.RELATIONSHIPID) AS RELATIONSHIPID FROM personaltable PR WHERE PR.BRANCHID=1 AND PR.FIRSTNAME='" + txtledgername.Text.Trim().ToString() + "'";
            Handler hdn = new Handler();
            DataTable dt = hdn.GetTable(sql);
            personalrelation objpersonalrelation = new personalrelation(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            objpersonalrelation.personalrelation_SRNO = -1;
            objpersonalrelation.personalrelation_RELATIONSHIPID = General.Parse<int>(dt.Rows[0][0].ToString());
            objpersonalrelation.personalrelation_ASSOSIATEDFEILD = txtfeild.Text.Trim().ToString();
            objpersonalrelation.personalrelation_ASSOSIATEDBRANCH = General.Parse<int>(Session["branchid"].ToString());
            objpersonalrelation.personalrelation_GROUPID = General.Parse<int>(ddlsubgroup.SelectedValue.ToString());
            objpersonalrelation.personalrelation_STATUS = 0;
            check = 1;
            if (objpersonalrelation.Insert(true, "personalrelation"))
            {
                string sqlperrelation = "SELECT MAX(PR.SRNO) AS SRNO FROM personalrelation PR WHERE PR.STATUS=0 AND PR.RELATIONSHIPID=" + dt.Rows[0][0].ToString() + " AND PR.ASSOSIATEDBRANCH=1";
                Handler hdn1 = new Handler();
                DataTable dt1 = hdn1.GetTable(sqlperrelation);

                Handler objopening = new Handler();
                DataTable dtopening = objopening.GetTable("SELECT SRNO,RELATIONSHIPID FROM PERSONALRELATION WHERE ASSOSIATEDBRANCH =1 and ASSOSIATEDFEILD = 'OPENING ACCOUNT'");

                transactiontable objtransaction = new transactiontable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                objtransaction.transactiontable_SRNO = -1;
                objtransaction.transactiontable_LEDGER1 = General.Parse<int>(dt1.Rows[0]["SRNO"].ToString());
                objtransaction.transactiontable_RELATIONID1 = General.Parse<int>(dt.Rows[0]["RELATIONSHIPID"].ToString());

                objtransaction.transactiontable_LEDGER2 = General.Parse<int>(dtopening.Rows[0]["SRNO"].ToString());
                objtransaction.transactiontable_RELATIONID2 = General.Parse<int>(dtopening.Rows[0]["RELATIONSHIPID"].ToString());

                if (rdcredit.Checked)
                {
                    objtransaction.transactiontable_LTRNTYPE1 = "CR";
                    objtransaction.transactiontable_LTRNTYPE2 = "DR";
                }
                else
                {
                    objtransaction.transactiontable_LTRNTYPE1 = "DR";
                    objtransaction.transactiontable_LTRNTYPE2 = "CR";
                }
                objtransaction.transactiontable_AMOUNT = General.Parse<double>(txtamt.Text.Trim().ToString());
                objtransaction.transactiontable_BRANCHID = General.Parse<int>(Session["branchid"].ToString());
                objtransaction.transactiontable_TRANSDATE = DateTime.Today.ToString("dd/MM/YYYY");
                objtransaction.transactiontable_VOUCHERNO = "1";
                objtransaction.transactiontable_VOUCHERTYPE = "OPENING AMOUNT";
                objtransaction.transactiontable_TRANSACTIONTYPE = 7; //type for opening amount 
                objtransaction.transactiontable_NARRATION = "OPENING AMOUNT";
                objtransaction.transactiontable_STATUS = 0;
                if (objtransaction.Insert(true, "transactiontable"))
                {
                    string sqltransaction = "SELECT MAX(TT.SRNO) AS SRNO FROM transactiontable TT WHERE LEDGER1=" + dt1.Rows[0]["SRNO"].ToString() + " AND TT.LEDGER2=" + dtopening.Rows[0]["SRNO"].ToString() + " AND STATUS=0";
                    Handler hdntransaction = new Handler();
                    DataTable dttransaction = hdntransaction.GetTable(sqltransaction);
                    for(int i=0;i<2;i++)
                    {
                        TransactionDetailsC objtransactiondetails = new TransactionDetailsC(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                        if (i == 0)
                        {
                            objtransactiondetails.transactiondetails_LTRNTYPE = objtransaction.transactiontable_LTRNTYPE1.ToString();
                            objtransactiondetails.transactiondetails_LEDGERID = General.Parse<int>(dt1.Rows[0]["SRNO"].ToString());
                            objtransactiondetails.transactiondetails_RELATIONID = General.Parse<int>(dt.Rows[0]["RELATIONSHIPID"].ToString());
                        }
                        else
                        {
                            objtransactiondetails.transactiondetails_LTRNTYPE = objtransaction.transactiontable_LTRNTYPE2.ToString();
                            objtransactiondetails.transactiondetails_LEDGERID = General.Parse<int>(dtopening.Rows[0]["SRNO"].ToString());
                            objtransactiondetails.transactiondetails_RELATIONID = General.Parse<int>(dtopening.Rows[0]["RELATIONSHIPID"].ToString());
                        }
                        
                        objtransactiondetails.transactiondetails_SRNO = -1;
                        objtransactiondetails.transactiondetails_STATUS = 0;
                      
                        objtransactiondetails.transactiondetails_TRANSDATE = DateTime.Today.ToString("dd/MM/YYYY");
                        objtransactiondetails.transactiondetails_NARRATION = "OPENING AMOUNT";
                        objtransactiondetails.transactiondetails_VOUCHERTYPE = "OPENING AMOUNT";
                        objtransactiondetails.transactiondetails_BRANCHID = General.Parse<int>(Session["branchid"].ToString()); //1;
                        objtransactiondetails.transactiondetails_AMOUNT = General.Parse<double>(txtamt.Text.Trim().ToString());
                        objtransactiondetails.transactiondetails_ASSOCIATELEDGER = General.Parse<int>(dttransaction.Rows[0]["SRNO"].ToString());
                        if (objtransactiondetails.Insert(true, "transactiondetails"))
                        {
                        }
                    }
                    //objtransactiondetails.
                }
            }
        }
        if (check == 1)
        {
            Response.Redirect("ledgerdetails.aspx?id=1");
        }
        else
        {
            MessageBox("Please Enter Proper Value");
        }
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        string sqlcheck = "SELECT RTRIM(SRNO) AS TRANSPORTERNO FROM TRANSPORTERMASTER TM WHERE TRANSPORTERCODE='" + txttransportercode.Text.Trim().ToString() + "'";
        Handler hdncheck = new Handler();
        DataTable dtcheck = hdncheck.GetTable(sqlcheck);
        if (dtcheck.Rows.Count == 0)
        {
            transportermaster objtransporter = new transportermaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            objtransporter.transportermaster_SRNO = -1;
            objtransporter.transportermaster_TRANSPORTERNAME = txttransportername.Text.Trim().ToString();
            objtransporter.transportermaster_TRANSPORTERCODE = txttransportercode.Text.Trim().ToString();
            if (rdlocal.Checked == true)
            {
                objtransporter.transportermaster_TRANTYPE = "LOCAL";
                objtransporter.transportermaster_TRANTYPECODE = 1;
            }
            else
            {
                objtransporter.transportermaster_TRANTYPE = "REMOTE";
                objtransporter.transportermaster_TRANTYPECODE = 2;
            }
            objtransporter.transportermaster_MOBILENO = txtphone.Text.Trim().ToString();
            objtransporter.transportermaster_FAX = txtfax.Text.Trim().ToString();
            if (txtemail.Text.Trim().ToString() != string.Empty)
            {
                objtransporter.transportermaster_EMAILID = txtemail.Text.Trim().ToString();
            }
            objtransporter.transportermaster_PANNO = txtpano.Text.Trim().ToString();
            objtransporter.transportermaster_SERVICETAXNO = txtservicetaxno.Text.Trim().ToString();
            objtransporter.transportermaster_ADDRESS = txtaddress.Text.Trim().ToString();
            objtransporter.transportermaster_STATUS = 0;
            if (objtransporter.Insert(true, "transportermaster"))
            {
                string sqlmax = "SELECT MAX(SRNO) AS SRNO FROM TRANSPORTERMASTER TM WHERE STATUS=0 AND TRANSPORTERNAME='" + txttransportername.Text.Trim().ToString() + "' AND TRANSPORTERCODE='" + txttransportercode.Text.Trim().ToString() + "'";
                Handler hdnmax = new Handler();
                DataTable dtmax = hdnmax.GetTable(sqlmax);

                if (rdserviceapplicable.Checked == true)
                {
                    string sqltax = "SELECT SRNO,TAXNAME,TAXUNIT,TAXVALUE FROM TAXMASTER TM WHERE TM.STATUS=0 AND TM.TAXNAME='SERVICE TAX'";
                    Handler hdntax = new Handler();
                    DataTable dttax = hdntax.GetTable(sqltax);
                    taxationmaster objtax = new taxationmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objtax.taxationmaster_SRNO = -1;
                    objtax.taxationmaster_TAXPARTYTYPE = "TRANSPORTER";
                    objtax.taxationmaster_TAXPARTYID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                    objtax.taxationmaster_TAXID = General.Parse<int>(dttax.Rows[0]["SRNO"].ToString());
                    objtax.taxationmaster_TAXNAME = dttax.Rows[0]["TAXNAME"].ToString().Trim();
                    objtax.taxationmaster_TAXVALUE = General.Parse<double>(dttax.Rows[0]["TAXVALUE"].ToString().Trim());
                    objtax.taxationmaster_TAXUNIT = dttax.Rows[0]["TAXUNIT"].ToString().Trim();
                    objtax.taxationmaster_STATUS = 0;
                    if (objtax.Insert(true, "taxationmaster"))
                    {
                    }
                }
                if (dtmax.Rows.Count > 0 && memberrepeater.Items.Count > 0)
                {
                    for (int i = 0; i < memberrepeater.Items.Count; i++)
                    {

                        TextBox name = (TextBox)memberrepeater.Items[i].FindControl("txtpersonname");

                        TextBox phone = (TextBox)memberrepeater.Items[i].FindControl("txtperphone");
                        TextBox email = (TextBox)memberrepeater.Items[i].FindControl("txtperemailid");
                        TextBox mobile = (TextBox)memberrepeater.Items[i].FindControl("txtpermobile");

                        personalmaster objpersonal = new personalmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                        objpersonal.personalmaster_SRNO = -1;
                        objpersonal.personalmaster_PERSONNAME = name.Text.ToString().Trim();
                        if (email.Text.ToString().Trim() != string.Empty)
                        {
                            objpersonal.personalmaster_EMAILID = email.Text.ToString().Trim();
                        }
                        objpersonal.personalmaster_PHONENO = phone.Text.ToString().Trim();
                        objpersonal.personalmaster_MOBILE = mobile.Text.ToString().Trim();
                        objpersonal.personalmaster_PERSONRELATIONID = General.Parse<int>(dtmax.Rows[0][0].ToString());
                        objpersonal.personalmaster_PERSONTYPE = "TRANSPORTER";
                        if (objpersonal.Insert(true, "personalmaster"))
                        {
                        }

                    }
                }
                personaltable objpersonal1 = new personaltable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                objpersonal1.personaltable_RELATIONSHIPID = -1;
                objpersonal1.personaltable_FIRSTNAME = txttransportername.Text.Trim().ToString();
                objpersonal1.personaltable_BRANCHID = General.Parse<int>(Session["branchid"].ToString());
                Handler branch = new Handler();
                DataTable dtbranch = branch.GetTable("select BRANCHNAME from branchmaster where branchid=" + Session["branchid"].ToString());
                objpersonal1.personaltable_BRANCHNAME = dtbranch.Rows[0][0].ToString().Trim();
                if (objpersonal1.Insert(true, "personaltable"))
                {
                    string sql = "SELECT MAX(PR.RELATIONSHIPID) AS RELATIONSHIPID FROM personaltable PR WHERE PR.BRANCHID=1 AND PR.FIRSTNAME='" + txttransportername.Text.Trim().ToString() + "'";
                    Handler hdn = new Handler();
                    DataTable dt = hdn.GetTable(sql);
                    personalrelation objpersonalrelation = new personalrelation(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                    objpersonalrelation.personalrelation_SRNO = -1;
                    objpersonalrelation.personalrelation_RELATIONSHIPID = General.Parse<int>(dt.Rows[0][0].ToString());
                    objpersonalrelation.personalrelation_ASSOSIATEDFEILD = "MAIN ACCOOUNT";
                    objpersonalrelation.personalrelation_ASSOSIATEDBRANCH = General.Parse<int>(Session["branchid"].ToString());
                    objpersonalrelation.personalrelation_GROUPID = 100;
                    objpersonalrelation.personalrelation_STATUS = 0;
                    if (objpersonalrelation.Insert(true, "personalrelation"))
                    {
                    }
                }
                MessageBox("Transporter Added Successfully");
                Response.Redirect("transporterlist.aspx?ID=2");
                //Response.Redirect("transporterdetails.aspx?ID=1&TRANSPORTERID=" + dtmax.Rows[0][0].ToString());
            }
        }
        else
        {
            MessageBox("Transporter Code Already  Exist");
        }
    }