Ejemplo n.º 1
0
        private void dataThu_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGoiTap.CurrentCell.ColumnIndex.Equals(11) && e.RowIndex != -1)
            {
                con.Open();
                if (dataGoiTap.CurrentCell != null && dataGoiTap.CurrentCell.Value != null)
                {
                    if (SubClasses.GetDataGoiTap.UpdateModeOn == true)
                    {
                        MessageBox.Show("Bạn không thể thực hiện thao tác này");
                    }
                    else
                    {
                        string del = dataGoiTap.Rows[e.RowIndex].Cells[0].Value.ToString();
                        if (UserInfo.userName == "admin")
                        {
                            if ((MessageBox.Show("Xác nhận XOÁ toàn bộ thông tin của gói tập: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                            {
                                KHCmd = new SqlCommand("EXECUTE dbo.IUD_GOITAP '" + del + "',N'','','','',N'',N'',N'','',N'Delete'", con);
                                KHCmd.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            if ((MessageBox.Show("Xác nhận XOÁ gói tập: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                            {
                                KHCmd = new SqlCommand("EXECUTE dbo.IUD_GOITAP '" + del + "',N'','','','',N'',N'',N'','',N'Hide'", con);
                                KHCmd.ExecuteNonQuery();
                            }
                        }
                    }
                }
                con.Close();
                DisplayData();
            }
            if (dataGoiTap.CurrentCell.ColumnIndex.Equals(10) && e.RowIndex != -1)
            {
                con.Open();
                if (dataGoiTap.CurrentCell != null && dataGoiTap.CurrentCell.Value != null)
                {
                    if ((MessageBox.Show("Bạn chỉ có thể chỉnh sửa các nội dung như: Ngày bắt đầu/kết thúc, Giá, Ca tập, Buổi tập, Khu vực tập. Bạn có muốn tiếp tục", "Xác nhận cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        SubClasses.GetDataGoiTap.UpdateModeOn = true;
                        SubClasses.GetDataGoiTap.maGoi        = dataGoiTap.Rows[e.RowIndex].Cells[0].Value.ToString();
                        SubClasses.GetDataGoiTap.tenGoi       = dataGoiTap.Rows[e.RowIndex].Cells[1].Value.ToString();
                        SubClasses.GetDataGoiTap.gia          = dataGoiTap.Rows[e.RowIndex].Cells[2].Value.ToString();
                        SubClasses.GetDataGoiTap.ngayBD       = Convert.ToDateTime(dataGoiTap.Rows[e.RowIndex].Cells[3].Value.ToString());
                        SubClasses.GetDataGoiTap.ngayKT       = Convert.ToDateTime(dataGoiTap.Rows[e.RowIndex].Cells[4].Value.ToString());
                        SubClasses.GetDataGoiTap.buoi         = dataGoiTap.Rows[e.RowIndex].Cells[5].Value.ToString();
                        SubClasses.GetDataGoiTap.ca           = dataGoiTap.Rows[e.RowIndex].Cells[6].Value.ToString();
                        SubClasses.GetDataGoiTap.khuVuc       = dataGoiTap.Rows[e.RowIndex].Cells[7].Value.ToString();
                        SubClasses.GetDataGoiTap.nguoiDK      = dataGoiTap.Rows[e.RowIndex].Cells[8].Value.ToString();

                        SubForms.ThemGoiTap themGOI = new SubForms.ThemGoiTap();
                        themGOI.ShowDialog();
                        con.Close();
                        DisplayData();
                    }
                }
            }
            if (dataGoiTap.CurrentCell.ColumnIndex.Equals(9) && e.RowIndex != -1)
            {
                if (dataGoiTap.CurrentCell != null && dataGoiTap.CurrentCell.Value != null)
                {
                    if (dataGoiTap.Rows[e.RowIndex].Cells[9].Value.ToString() == "True" && UserInfo.privilege == "high")
                    {
                        if ((MessageBox.Show("Khôi phục dữ liệu bị ẩn", "Xác nhận cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                        {
                            con.Open();
                            string magoitap = dataGoiTap.Rows[e.RowIndex].Cells[0].Value.ToString();
                            KHCmd = new SqlCommand("EXECUTE dbo.IUD_GOITAP '" + magoitap + "',N'','','','',N'',N'',N'','',N'Show'", con);
                            KHCmd.ExecuteNonQuery();
                            con.Close();
                            DisplayData();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     SubForms.ThemGoiTap themGOI = new SubForms.ThemGoiTap();
     themGOI.ShowDialog();
     DisplayData();
 }