private void addToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //Add
     NewInfo a = new NewInfo();
     a.type = "0";
     a.ShowDialog();
     LoadData();
 }
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Edit
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("Please choose 1 row for editing");
                return;
            }
            NewInfo a = new NewInfo();
            a.type = "1";
            a.ref_no = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            a.useridcreate_edit = dataGridView1[13, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //a.ID = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            a.ShowDialog();
            LoadData();

            ////kiem tra quyen edit
            //string sql = "", err = "";
            //sql = "select aa.name, aa.department from "+Businessbp.executedb.owner+"app_users aa" +
            //    " where aa.userid='" + Businessbp.executedb.Usrid + "'";
            //DataTable dt = Businessbp.executedb.getTable(sql, ref err);
            //if (err != "")
            //{
            //    MessageBox.Show(err);
            //    return;
            //}
            //else
            //{
            //    if (dt.Rows[0][1].ToString().ToUpper() == "TT.DVKH")
            //    {
            //        sql = "select aa.name, aa.department from "+Businessbp.executedb.owner+"app_users aa" +
            //            " where aa.userid= (select nv_nhan_kn from "+Businessbp.executedb.owner+"khieu_nai bb where bb.ref_no='" + dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString() + "')";

            //        DataTable dtedit = Businessbp.executedb.getTable(sql, ref err);
            //        if (err != "")
            //        {
            //            MessageBox.Show(err);
            //            return;
            //        }
            //        else
            //        {
            //            if (dtedit.Rows[0][1].ToString().ToUpper() == "TT.DVKH")
            //            {
            //                NewInfo a = new NewInfo();
            //                a.type = "1";
            //                a.ref_no = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //                a.useridcreate_edit = dataGridView1[13, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //                //a.ID = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //                a.ShowDialog();
            //                LoadData();
            //            }
            //            else
            //            {
            //                MessageBox.Show("Bạn không có quyền cập nhật dòng này");
            //                return;
            //            }
            //        }
            //    }
            //    else
            //    {
            //        NewInfo a = new NewInfo();
            //        a.type = "1";
            //        a.ref_no = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //        //a.ID = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
            //        a.ShowDialog();
            //        LoadData();
            //    }
            //}
        }
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     //Edit
     if (dataGridView1.Rows.Count == 0)
     {
         MessageBox.Show("Please choose 1 row for editing");
         return;
     }
     NewInfo a = new NewInfo();
     a.type = "1";
     a.ref_no = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
     a.useridcreate_edit = dataGridView1[13, dataGridView1.CurrentCell.RowIndex].Value.ToString();
     //a.ID = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
     a.ShowDialog();
     LoadData();            
 }