Example #1
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     SubForms.ThemDungCu themDC = new SubForms.ThemDungCu();
     themDC.ShowDialog();
     DisplayData();
 }
Example #2
0
        private void dataDungCu_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataDungCu.CurrentCell.ColumnIndex.Equals(9) && e.RowIndex != -1)
            {
                con.Open();
                if (dataDungCu.CurrentCell != null && dataDungCu.CurrentCell.Value != null)
                {
                    if (SubClasses.GetDataDC.UpdateModeOn == true)
                    {
                        MessageBox.Show("Bạn không thể thực hiện thao tác này");
                    }
                    else
                    {
                        string del = dataDungCu.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 dụng cụ: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                            {
                                KHCmd = new SqlCommand("EXECUTE dbo.IUD_DUNGCU '" + del + "',N'','',N'','',N'',N'Delete'", con);
                                KHCmd.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            if ((MessageBox.Show("Xác nhận XOÁ dụng cụ: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                            {
                                KHCmd = new SqlCommand("EXECUTE dbo.IUD_DUNGCU '" + del + "',N'','',N'','',N'',N'Hide'", con);
                                KHCmd.ExecuteNonQuery();
                            }
                        }
                    }
                }
                con.Close();
                DisplayData();
            }
            if (dataDungCu.CurrentCell.ColumnIndex.Equals(8) && e.RowIndex != -1)
            {
                if (dataDungCu.CurrentCell != null && dataDungCu.CurrentCell.Value != null)
                {
                    if ((MessageBox.Show("Xác nhận chỉnh sửa thông tin dụng cụ", "Xác nhận cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        SubClasses.GetDataDC.UpdateModeOn = true;
                        SubClasses.GetDataDC.maDC = dataDungCu.Rows[e.RowIndex].Cells[0].Value.ToString();
                        SubClasses.GetDataDC.tenDC = dataDungCu.Rows[e.RowIndex].Cells[1].Value.ToString();
                        SubClasses.GetDataDC.gia = dataDungCu.Rows[e.RowIndex].Cells[2].Value.ToString();
                        SubClasses.GetDataDC.tinhTrang = dataDungCu.Rows[e.RowIndex].Cells[3].Value.ToString();
                        SubClasses.GetDataDC.ngayMua = Convert.ToDateTime(dataDungCu.Rows[e.RowIndex].Cells[4].Value.ToString());
                        SubClasses.GetDataDC.ngaySD = dataDungCu.Rows[e.RowIndex].Cells[5].Value.ToString();
                        SubClasses.GetDataDC.KVSD = dataDungCu.Rows[e.RowIndex].Cells[6].Value.ToString();

                        SubForms.ThemDungCu themDC = new SubForms.ThemDungCu();
                        themDC.ShowDialog();
                        if (SubClasses.GetDataDC.UpdateModeOn == false) DisplayData();
                    }
                }
                con.Close();
            }
            if (dataDungCu.CurrentCell.ColumnIndex.Equals(7) && e.RowIndex != -1)
            {
                if (dataDungCu.CurrentCell != null && dataDungCu.CurrentCell.Value != null)
                {
                    if (dataDungCu.Rows[e.RowIndex].Cells[7].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 maDC = dataDungCu.Rows[e.RowIndex].Cells[0].Value.ToString();
                            KHCmd = new SqlCommand("EXECUTE dbo.IUD_DUNGCU '" + maDC + "',N'','',N'','',N'',N'Show'", con);
                            KHCmd.ExecuteNonQuery();
                            con.Close();
                            DisplayData();
                        }
                    }
                }
            }
        }