Example #1
0
        private void FrmDailyBusEntry_Load(object sender, EventArgs e)
        {
            try
            {
                ShowData();
                // DataSet ds2 = Connection.GetDataSet("select EmpTypeId from tbl_EmployeeType where Detail='Teacher'");
                DataSet ds3 = Connection.GetDataSet("select EmpName from tbl_EmployeeInfo where designation='Driver'  select EmpName from tbl_EmployeeInfo where designation='Conductor'  select EmpName from tbl_EmployeeInfo where EmpTypeId='1001' ");
                cmbDriverName.DataSource       = ds3.Tables[0];
                cmbDriverName.DisplayMember    = "EmpName";
                cmbConductorName.DataSource    = ds3.Tables[1];
                cmbConductorName.DisplayMember = "EmpName";
                cmbTeacherName.DataSource      = ds3.Tables[2];
                cmbTeacherName.DisplayMember   = "EmpName";
                c.GetMdiParent(this).EnableAllEditMenuButtons();

                dgv1.Enabled = false;
                DesignForm.fromDesign1(this);
            }
            catch { }
        }
Example #2
0
        private void FrmJournalVoucher_Load(object sender, EventArgs e)
        {
            c.GetMdiParent(this).EnableAllEditMenuButtons();

            c.getconnstr();
            ds = new DataSet();
            ds = c.GetDataSet("select accode,acname from  tbl_account");
            ds.WriteXmlSchema(@"" + Connection.GetAccessPathId() + @"Barcodes\a\DStbl_account.xsd");
            c.FillcomboBox("select acname,accode from tbl_account  order by acname", "acname", "accode", ref valcmbbank);
            //c.FillcomboBox("select * from tbl_account order by acname", "acname", "accode", ref valcmbaccountgroup);
            txtsession.Text = Convert.ToString(school.CurrentSessionCode);
            for (int i = 0; i <= 25; i++)
            {
                dtgbook.Rows.Add();
                DataGridViewComboBoxCell ComboColumn = (DataGridViewComboBoxCell)(dtgbook.Rows[i].Cells[0]);
                ComboColumn.DisplayMember = "acname";
                ComboColumn.ValueMember   = "accode";
                ComboColumn.DataSource    = ds.Tables[0];
            }
            DesignForm.fromDesign1(this);
        }
Example #3
0
 public override void btncancel_Click(object sender, EventArgs e)
 {
     add_edit = false;
     DesignForm.fromDesign1(this);
     c.GetMdiParent(this).EnableAllEditMenuButtons();
 }
Example #4
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            if (ATxtScholar.Text == "" || txthostelfee.Text == "" || txtmessdays.Text == "" || txtyear.Text == "" || txtmessfee.Text == "")
            {
                MessageBox.Show("Null Value Not Allowed");
            }

            else
            {
                SqlTransaction trn;

                if (add_edit == true)
                {
                    c.returnconn(c.myconn);
                    SqlCommand command = new SqlCommand("select isnull(max(feeno),0) as maxfee from tbl_hostelfee", c.myconn);
                    command.CommandTimeout = 120;
                    Int32 mfeeno;
                    mfeeno = 1001;
                    if (command.ExecuteScalar() != System.DBNull.Value)
                    {
                        mfeeno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                    }
                    textBox1.Text = mfeeno.ToString();
                    c.returnconn(c.myconn);
                    trn = c.myconn.BeginTransaction();

                    try
                    {
                        if (txtmessdays.Text == "")
                        {
                            txtmessdays.Text = "0";
                        }

                        if (txtmessfee.Text == "")
                        {
                            txtmessfee.Text = "0";
                        }
                        mysql = "update tbl_hostelfee set rechostelfee=" + txthostelfee.Text + ",recmessfee=" + txtmessfee.Text + ",messdays=" + txtmessdays.Text + ", feeno=" + textBox1.Text + ",feedate= '" + dtpfee.Value.ToString("MM/dd/yyyy") + "' where studentno='" + lblstudentno.Text + "' and sessioncode=" + school.CurrentSessionCode + " and monthno=" + (cmbmonth.SelectedIndex + 1) + " and yearno=" + txtyear.Text;
                        c.connectsql(mysql, c.myconn, trn);
                        trn.Commit();
                        MessageBox.Show("Fee Saved..");

                        ShowFeeDetails();
                        DesignForm.fromDesign1(this);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        trn.Rollback();
                    }
                }
                if (add_edit == false)
                {
                    c.returnconn(c.myconn);
                    trn = c.myconn.BeginTransaction();

                    try
                    {
                        DataSet ds    = Connection.GetDataSet("select feeno from tbl_hostelfee where monthno='" + (cmbmonth.SelectedIndex + 1) + "'");
                        int     feeno = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                        ATxtScholar.Text = feeno.ToString();
                        string mysql1;
                        mysql1 = "update tbl_hostelfee set rechostelfee=" + txthostelfee.Text + ",recmessfee=" + txtmessfee.Text + ",messdays=" + txtmessdays.Text + ", feeno=" + textBox1.Text + ",feedate= '" + dtpfee.Value.ToString("MM/dd/yyyy") + "' where feeno='" + feeno + "'";
                        c.connectsql(mysql1, c.myconn, trn);
                        trn.Commit();
                        MessageBox.Show("Fee Saved..");
                        ShowFeeDetails();
                        DesignForm.fromDesign1(this);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        trn.Rollback();
                    }
                }


                c.GetMdiParent(this).EnableAllEditMenuButtons();
            }
        }
Example #5
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            int bank1;
            int bank2;

            bank1 = Convert.ToInt16(valcmbaccountgroup.SelectedValue);
            bank2 = Convert.ToInt16(valcmbbank.SelectedValue);
            if (bank1 == bank2)
            {
                MessageBox.Show("Both Accounts are same...");
                goto mline;
            }
            txtvchtype.Text = "BR";
            txtsession.Text = Convert.ToString(school.CurrentSessionCode);
            if (add_edit == true)
            {
                c.returnconn(c.myconn);
                SqlCommand command = new SqlCommand("select max(vchno) from tbl_voucher where  sessioncode=" + txtsession.Text + " and  vchtype='" + txtvchtype.Text + "'", c.myconn);
                command.CommandTimeout = 120;
                Int32 mstudentno;
                mstudentno = 1000001;
                if (command.ExecuteScalar() != System.DBNull.Value)
                {
                    mstudentno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                }
                txtvoucherno.Text = mstudentno.ToString();
                c.insertdata("tbl_voucher", c.myconn, this);
                SqlTransaction trn;
                trn = c.myconn.BeginTransaction();
                string mysql;
                int    i = 0;
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbbank.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Dr')";
                c.connectsql(mysql, c.myconn, trn);
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Cr')";
                c.connectsql(mysql, c.myconn, trn);
                if (dtgbook.Rows.Count > 0)
                {
                    while (i <= dtgbook.Rows.Count - 1)
                    {
                        double mval = Convert.ToDouble(dtgbook.Rows[i].Cells[2].Value);
                        if (mval > 0)
                        {
                            mysql = "insert into tbl_subledger (sessioncode,vchtype,vchno,accode,subledgercode,subledgamt,vchdate,amttype,narration) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + dtgbook.Rows[i].Cells[0].Value + "," + mval + ",'" + dtp.Value.Date + "','Cr','" + dtgbook.Rows[i].Cells[3].Value + "')";
                            c.connectsql(mysql, c.myconn, trn);
                        }
                        i++;
                    }
                }
                trn.Commit();
                DesignForm.fromDesign1(this);
            }
            if (add_edit == false)
            {
                c.returnconn(c.myconn);
                SqlTransaction trn;
                trn = c.myconn.BeginTransaction();
                //*--delete prvious voucher-------------
                c.connectsql("delete from tbl_voucher where sessioncode=" + txtsession.Text + " and vchtype='BR'  and vchno=" + txtvoucherno.Text, c.myconn, trn);
                trn.Commit();
                c.insertdata("tbl_voucher", c.myconn, this);
                trn = c.myconn.BeginTransaction();
                //*--delete prvious voucher-------------
                c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='BR' and amttype='Dr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='BR' and amttype='Cr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                c.connectsql("delete from tbl_subledger where sessioncode=" + txtsession.Text + " and vchtype='BR' and amttype='Cr' and vchno=" + txtvoucherno.Text, c.myconn, trn);

                //*------------------
                string mysql;
                int    i = 0;
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbbank.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Dr')";
                c.connectsql(mysql, c.myconn, trn);
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Cr')";
                c.connectsql(mysql, c.myconn, trn);
                if (dtgbook.Rows.Count > 0)
                {
                    while (i <= dtgbook.Rows.Count - 1)
                    {
                        double mval = Convert.ToDouble(dtgbook.Rows[i].Cells[2].Value);
                        if (mval > 0)
                        {
                            mysql = "insert into tbl_subledger (sessioncode,vchtype,vchno,accode,subledgercode,subledgamt,vchdate,amttype,narration) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + dtgbook.Rows[i].Cells[0].Value + "," + mval + ",'" + dtp.Value.Date + "','Cr','" + dtgbook.Rows[i].Cells[3].Value + "')";
                            c.connectsql(mysql, c.myconn, trn);
                        }
                        i++;
                    }
                }
                trn.Commit();
                DesignForm.fromDesign1(this);
            }
            MessageBox.Show("Record Saved...", "School");
mline:
            c.GetMdiParent(this).EnableAllEditMenuButtons();
        }
Example #6
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" && textBox2.Text == "")
            {
                MessageBox.Show("Null Value Not Allowed ");
            }
            else
            {
                //-----------
                int           cactype  = 0;
                SqlCommand    command2 = new SqlCommand("select dbo.GetAccountCode('C') as CCode", c.myconn);
                SqlDataReader reader2  = command2.ExecuteReader();
                if (reader2.HasRows)
                {
                    reader2.Read();
                    cactype = Convert.ToInt16(reader2["CCode"]);
                    reader2.Close();
                }
                else
                {
                    reader2.Close();
                }
                //-----------
                SqlCommand    command1 = new SqlCommand("select actype from tbl_account where accode='" + valcmbaccountgroup.SelectedValue + "'", c.myconn);
                SqlDataReader reader1  = command1.ExecuteReader();
                int           i        = 0;
                if (reader1.HasRows)
                {
                    reader1.Read();
                    int actype;
                    actype = Convert.ToInt16(reader1["actype"]);
                    if (actype == cactype)
                    {
                        MessageBox.Show("Cannot Select Cash Account..");
                        reader1.Close();
                        goto mline;
                    }
                }

                txtvchtype.Text = "CP";
                txtsession.Text = Convert.ToString(school.CurrentSessionCode);
                if (add_edit == true)
                {
                    c.returnconn(c.myconn);
                    SqlCommand command = new SqlCommand("select max(vchno) from tbl_voucher where   sessioncode=" + txtsession.Text + " and  vchtype='" + txtvchtype.Text + "' and RefNo='JV'", c.myconn);
                    command.CommandTimeout = 120;
                    Int32 mstudentno;
                    mstudentno = 10001;
                    if (command.ExecuteScalar() != System.DBNull.Value)
                    {
                        mstudentno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                    }
                    txtRefNo.Text     = "JV";
                    txtvoucherno.Text = mstudentno.ToString();
                    c.insertdata("tbl_voucher", c.myconn, this);
                    SqlTransaction trn;
                    trn = c.myconn.BeginTransaction();
                    string mysql;
                    mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + ",(dbo.GetCashAccountCode('C'))," + textBox1.Text + ",'" + dtp.Value.Date + "','Cr')";
                    c.connectsql(mysql, c.myconn, trn);
                    mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Dr')";
                    c.connectsql(mysql, c.myconn, trn);
                    if (dtgbook.Rows.Count > 0)
                    {
                        while (i <= dtgbook.Rows.Count - 1)
                        {
                            double mval = Convert.ToDouble(dtgbook.Rows[i].Cells[2].Value);
                            if (mval > 0)
                            {
                                mysql = "insert into tbl_subledger (sessioncode,vchtype,vchno,accode,subledgercode,subledgamt,vchdate,amttype,narration) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + dtgbook.Rows[i].Cells[0].Value + "," + mval + ",'" + dtp.Value.Date + "','Dr','" + dtgbook.Rows[i].Cells[3].Value + "')";
                                c.connectsql(mysql, c.myconn, trn);
                            }
                            i++;
                        }
                    }
                    trn.Commit();
                    DesignForm.fromDesign1(this);
                }
                if (add_edit == false)
                {
                    c.returnconn(c.myconn);
                    SqlTransaction trn;
                    trn = c.myconn.BeginTransaction();
                    //*--delete prvious voucher-------------
                    c.connectsql("delete from tbl_voucher where sessioncode=" + txtsession.Text + " and vchtype='CP'  and vchno=" + txtvoucherno.Text, c.myconn, trn);
                    trn.Commit();
                    c.insertdata("tbl_voucher", c.myconn, this);
                    trn = c.myconn.BeginTransaction();

                    //*--delete prvious voucher details-------------
                    c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='CP' and amttype='Cr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                    c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='CP' and amttype='Dr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                    c.connectsql("delete from tbl_subledger where sessioncode=" + txtsession.Text + " and vchtype='CP' and amttype='Dr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                    //*------------------
                    string mysql;
                    mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + ",(dbo.GetCashAccountCode('C'))," + textBox1.Text + ",'" + dtp.Value.Date + "','Cr')";
                    c.connectsql(mysql, c.myconn, trn);
                    mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + textBox1.Text + ",'" + dtp.Value.Date + "','Dr')";
                    c.connectsql(mysql, c.myconn, trn);
                    if (dtgbook.Rows.Count > 0)
                    {
                        while (i <= dtgbook.Rows.Count - 1)
                        {
                            double mval = Convert.ToDouble(dtgbook.Rows[i].Cells[2].Value);
                            if (mval > 0)
                            {
                                mysql = "insert into tbl_subledger (sessioncode,vchtype,vchno,accode,subledgercode,subledgamt,vchdate,amttype,narration) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbaccountgroup.SelectedValue + "," + dtgbook.Rows[i].Cells[0].Value + "," + mval + ",'" + dtp.Value.Date + "','Dr','" + dtgbook.Rows[i].Cells[3].Value + "')";
                                c.connectsql(mysql, c.myconn, trn);
                            }
                            i++;
                        }
                    }
                    trn.Commit();
                    DesignForm.fromDesign1(this);
                }
                MessageBox.Show("Record Saved...", "School");
mline:
                c.GetMdiParent(this).EnableAllEditMenuButtons();
            }
        }
Example #7
0
 private void btncancel_Click(object sender, EventArgs e)
 {
     add_edit = false;
     c.btnenable(btnnew, btnedit, btndelete, btnsave, btncancel, btnprint, btnexit);
     DesignForm.fromDesign1(this);
 }
Example #8
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            int bank1 = 0;
            int bank2 = 0;

            //bank1 = Convert.ToInt16(valcmbaccountgroup.SelectedValue);
            bank2 = Convert.ToInt16(valcmbbank.SelectedValue);
            if (bank1 == bank2)
            {
                MessageBox.Show("Both Accounts are same...");
                goto mline;
            }
            txtRefNo.Text   = txtvchtype.Text = "JV";
            txtsession.Text = Convert.ToString(school.CurrentSessionCode);
            if (add_edit == true)
            {
                c.returnconn(c.myconn);
                SqlCommand command = new SqlCommand("select max(vchno) from tbl_voucher where   sessioncode=" + txtsession.Text + " and  vchtype='" + txtvchtype.Text + "' and RefNo='JV'", c.myconn);
                command.CommandTimeout = 120;
                Int32 mstudentno;
                mstudentno = 10001;
                if (command.ExecuteScalar() != System.DBNull.Value)
                {
                    mstudentno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                }
                txtvoucherno.Text = mstudentno.ToString();

                c.insertdata("tbl_voucher", c.myconn, this);
                SqlTransaction trn;
                trn = c.myconn.BeginTransaction();
                string mysql;
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype,type) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbbank.SelectedValue + "," + txtvchamt.Text + ",'" + dtp.Value.Date + "','" + strcmbdrcr.Text + "','S')";
                c.connectsql(mysql, c.myconn, trn);
                //----------------------------
                string amttype = strcmbdrcr.Text;
                if (amttype == "Cr")
                {
                    amttype = "Dr";
                }
                else
                {
                    amttype = "Cr";
                }
                for (int i = 0; i <= dtgbook.Rows.Count - 1; i++)
                {
                    if (Convert.ToDecimal(dtgbook.Rows[i].Cells[1].Value) > 0)
                    {
                        mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype,type) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + dtgbook.Rows[i].Cells[0].Value + "," + Convert.ToDecimal(dtgbook.Rows[i].Cells[1].Value) + ",'" + dtp.Value.Date + "','" + amttype + "','M')";
                        c.connectsql(mysql, c.myconn, trn);
                    }
                }
                trn.Commit();
                DesignForm.fromDesign1(this);
            }
            if (add_edit == false)
            {
                c.updatedata("tbl_voucher", c.myconn, this, "vchno", txtvoucherno.Text);
                SqlTransaction trn;
                trn = c.myconn.BeginTransaction();
                //*--delete prvious voucher-------------
                c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='JV' and amttype='Cr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                c.connectsql("delete from tbl_voucherdet where sessioncode=" + txtsession.Text + " and vchtype='JV' and amttype='Dr' and vchno=" + txtvoucherno.Text, c.myconn, trn);
                //*------------------
                string mysql;
                mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype,type) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + valcmbbank.SelectedValue + "," + txtvchamt.Text + ",'" + dtp.Value.Date + "','" + strcmbdrcr.Text + "','S')";
                c.connectsql(mysql, c.myconn, trn);
                //----------------------------
                string amttype = strcmbdrcr.Text;
                if (amttype == "Cr")
                {
                    amttype = "Dr";
                }
                else
                {
                    amttype = "Cr";
                }
                for (int i = 0; i <= dtgbook.Rows.Count - 1; i++)
                {
                    if (Convert.ToDecimal(dtgbook.Rows[i].Cells[1].Value) > 0)
                    {
                        mysql = "insert into tbl_voucherdet (sessioncode,vchtype,vchno,accode,vchamt,vchdate,amttype,type) values ('" + txtsession.Text + "','" + txtvchtype.Text + "'," + txtvoucherno.Text + "," + dtgbook.Rows[i].Cells[0].Value + "," + Convert.ToDecimal(dtgbook.Rows[i].Cells[1].Value) + ",'" + dtp.Value.Date + "','" + amttype + "','M')";
                        c.connectsql(mysql, c.myconn, trn);
                    }
                }
                //c.connectsql(mysql, c.myconn, trn);
                trn.Commit();
                DesignForm.fromDesign1(this);
            }
            MessageBox.Show("Record Saved...", "School");
mline:
            c.GetMdiParent(this).EnableAllEditMenuButtons();
        }
Example #9
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            if (txtaccountname.Text == string.Empty)
            {
                MessageBox.Show("Null Value Not Allowed ");
            }
            else
            {
                //c.datasave("tbl_account", c.myconn, this);
                //c.datasave ("insert into tbl_account values ('" +txtaccountname  + "','" + cmbaccountgroup.Text + "','" + txtaddress.Text + "','" + txtpanno.Text + "','" + txtopenbalance.Text + "')");
                if (add_edit == true)
                {
                    c.returnconn(c.myconn);
                    //SqlCommand command = new SqlCommand("select max(accode) from tbl_account where actype not in (dbo.GetAccountCode('F'),dbo.GetAccountCode('S'))", c.myconn);
                    SqlCommand command = new SqlCommand("select max(accode) from tbl_account ", c.myconn);
                    command.CommandTimeout = 120;
                    Int32 mstudentno;
                    mstudentno = 10001;
                    if (command.ExecuteScalar() != System.DBNull.Value)
                    {
                        mstudentno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                    }
                    DataSet ds = Connection.GetDataSet("select count(* ) from tbl_account where acname='" + txtaccountname.Text + "'");
                    int     i  = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                    if (i == 0)
                    {
                        txtacno.Text = mstudentno.ToString();
                        c.insertdata("tbl_account", c.myconn, this);
                    }
                    else
                    {
                        MessageBox.Show("Duplicate data not allowed");
                    }

                    if (chksubledger.Checked == true)
                    {
                        SqlTransaction trn;
                        trn = c.myconn.BeginTransaction();
                        c.connectsql("insert into tbl_subledger_account (subledgercode,accode) values (" + txtacno.Text + "," + valcmbparent.SelectedValue + ")", c.myconn, trn);
                        trn.Commit();
                        BtnSearch.Visible = false;
                    }
                    DesignForm.fromDesign1(this);
                }
                if (add_edit == false)
                {
                    c.updatedata("tbl_account", c.myconn, this, "accode", txtacno.Text);
                    SqlCommand command = new SqlCommand("select count(accode) from tbl_subledger_account where subledgercode=" + txtacno.Text, c.myconn);
                    command.CommandTimeout = 120;
                    Int32 mstudentno;
                    mstudentno = 10001;
                    if (command.ExecuteScalar() != System.DBNull.Value)
                    {
                        mstudentno = Convert.ToInt32(command.ExecuteScalar());
                    }
                    if (mstudentno != 0)
                    {
                        command = new SqlCommand("select count(accode) from tbl_subledger where subledgercode=" + txtacno.Text, c.myconn);
                        command.CommandTimeout = 120;
                        Int32 mstudentno1;
                        mstudentno1 = 0;
                        if (command.ExecuteScalar() != System.DBNull.Value)
                        {
                            mstudentno1 = Convert.ToInt32(command.ExecuteScalar());
                        }
                        if (chksubledger.Checked == false)
                        {
                            if (mstudentno1 != 0)
                            {
                                MessageBox.Show("Cannot Delete , Records already Exists in Sub Ledger file..");
                            }
                            else
                            {
                                c.getconnstr();
                                SqlTransaction trn;
                                trn = c.myconn.BeginTransaction();
                                c.connectsql("delete  from tbl_subledger_account where subledgercode=" + txtacno.Text, c.myconn, trn);
                                trn.Commit();
                            }
                        }
                    }

                    if (chksubledger.Checked == true)
                    {
                        SqlTransaction trn;
                        trn = c.myconn.BeginTransaction();
                        c.connectsql("delete  from tbl_subledger_account where subledgercode=" + txtacno.Text, c.myconn, trn);
                        c.connectsql("insert into tbl_subledger_account (subledgercode,accode) values ('" + txtacno.Text + "','" + valcmbparent.SelectedValue + "')", c.myconn, trn);
                        trn.Commit();
                    }
                    BtnSearch.Visible = false;
                    DesignForm.fromDesign1(this);
                }

                MessageBox.Show("Record Saved...", "School");
                c.FillListBox("select * from tbl_account", "acname", "accode", ref listBox1);
                c.FillcomboBox("select * from tbl_account", "acname", "accode", ref valcmbparent);
                c.GetMdiParent(this).EnableAllEditMenuButtons();
            }
        }