Пример #1
0
        // Open Update Author dialog
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (this.dgvReader.SelectedRows.Count > 0 &&
                this.dgvReader.SelectedRows[0].Index ==
                this.dgvReader.Rows.Count - 1)
            {
                MessageBox.Show("Xin chọn thông tin độc giả cần chỉnh sửa!");
                return;
            }
            int gioitinh = 0;

            if (radGTMale.Checked == true)
            {
                gioitinh = 1;
            }

            int colIndex = this.dgvReader.SelectedRows[0].Index;
            int authorId = int.Parse(this.dgvReader.Rows[colIndex].Cells[4].Value.ToString());

            var authorInfo = new DTO_DocGia(authorId, txtReaderName.Text, int.Parse(txtNK.Text), gioitinh);

            Edit_Reader editAuthor = new Edit_Reader(authorInfo);

            editAuthor.ShowDialog();
            this.ShowAuthorList();
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (dgvDocGia.SelectedRows.Count > 0)
            {
                if (tbxHoten.Text != "" && tbxDiaChi.Text != "" && tbxSDT.Text != "" && tbxCMND.Text != "")
                {
                    DataGridViewRow row = dgvDocGia.CurrentRow;

                    DTO_DocGia dtoDocGia = new DTO_DocGia(row.Cells[0].Value.ToString(), tbxHoten.Text, tbxDiaChi.Text, tbxSDT.Text, tbxCMND.Text, dtpNgaySinh.Value, dtpNgayDK.Value);

                    if (busDG.updateDocGia(dtoDocGia))
                    {
                        MessageBox.Show("Sửa thành công !");
                        dgvDocGia.DataSource = busDG.getDocGia();
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công !");
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin !");
                }
            }
        }
Пример #3
0
        public void ThemDocGia(DTO_DocGia dg)
        {
            string sql = string.Format("Insert into DocGia(HoTenDocGia, NgaySinh, DiaChi, Email, NgayLapThe, NgayHetHan)" +
                                       " values(N'{0}','{1}',N'{2}',N'{3}','{4}','{5}')", dg.UI_TenDocGia, dg.UI_NgaySinh,
                                       dg.UI_DiaChi, dg.UI_Email, dg.UI_NgayLapThe, dg.UI_NgayHetHan);

            cnn.ExecuteNonQuery(sql);
        }
Пример #4
0
        public void CapNhatDocGia(DTO_DocGia dg)
        {
            string sql = string.Format("update DocGia set" +
                                       "[HoTenDocGia]=N'{1}',[NgaySinh]='{2}',[DiaChi]=N'{3}',[Email]=N'{4}',[NgayLapThe]='{5}',[NgayHetHan]='{6}'" +
                                       " where [MaDocGia] = {0}", dg.UI_MaDocGia, dg.UI_TenDocGia, dg.UI_NgaySinh,
                                       dg.UI_DiaChi, dg.UI_Email, dg.UI_NgayLapThe, dg.UI_NgayHetHan);

            cnn.ExecuteNonQuery(sql);
        }
Пример #5
0
 public bool Bus_ThemDocGia(DTO_DocGia dg)
 {
     try
     {
         docgia.ThemDocGia(dg);
         return(true);
     }catch (Exception)
     {
         return(false);
     }
 }
Пример #6
0
 public Delete_Reader(DTO_DocGia ReaderInfo)
 {
     InitializeComponent();
     this.authorId      = ReaderInfo.MaDG;
     txtReaderName.Text = ReaderInfo.TenDG;
     txtNK.Text         = ReaderInfo.NienKhoa.ToString();
     if (ReaderInfo.GioiTinh == 0)
     {
         radGTFemale.Checked = true;
     }
     else
     {
         radGTMale.Checked = true;
     }
 }
Пример #7
0
        public bool ThemDocGia(DTO_DocGia DTO)
        {
            string    strSql    = "usp_ThemDocGia";
            DBConnect DBConnect = new DBConnect();

            DBConnect.Connect();
            try
            {
                DBConnect.ExecuteNonQuery(CommandType.StoredProcedure, strSql,
                                          new SqlParameter {
                    ParameterName = "@TenDG", Value = DTO._tenDG
                },
                                          new SqlParameter {
                    ParameterName = "@NgaySinhDG", Value = DTO._ngaySinh
                },
                                          new SqlParameter {
                    ParameterName = "@DiaChiDG", Value = DTO._DiaChiDG
                },
                                          new SqlParameter {
                    ParameterName = "@SDTDG", Value = DTO._SDT_DG
                },
                                          new SqlParameter {
                    ParameterName = "@EmailDG", Value = DTO._email
                },
                                          new SqlParameter {
                    ParameterName = "@CMNDDG", Value = DTO._CMND_DG
                },
                                          new SqlParameter {
                    ParameterName = "@MSSVDG", Value = DTO._MSSV_DG
                },
                                          new SqlParameter {
                    ParameterName = "@MCBDG", Value = DTO._MCB_DG
                },
                                          new SqlParameter {
                    ParameterName = "@LoaiDG", Value = DTO._LoaiDG
                });
                DBConnect.Disconnect();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #8
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (txt_Name.Text.Equals("") || txt_Address.Text.Equals("") || txt_Email.Text.Equals("") ||
         dtp_Date.Value.ToString().Equals("") || dtp_Create.Value.ToString().Equals("") ||
         dtp_Expired.Value.ToString().Equals(""))
     {
         MessageBox.Show("Sửa độc giả không thành công!\nBạn đã nhập thiếu thông tin! Hãy kiểm tra lại", "Lỗi");
     }
     else
     {
         try
         {
             int        madocgia = int.Parse(txt_MaDocGia.Text);
             string     name     = txt_Name.Text;
             DateTime   date     = dtp_Date.Value;
             string     address  = txt_Address.Text;
             string     email    = txt_Email.Text;
             DateTime   created  = dtp_Create.Value;
             DateTime   expired  = dtp_Expired.Value;
             DTO_DocGia d        = new DTO_DocGia(madocgia, name, date, address, email, created, expired);
             if (bus_DocGia.Bus_CapNhatDocGia(d) == true)
             {
                 MessageBox.Show("Sửa độc giả thành công!", "Thông báo");
                 txt_Name.Clear();
                 txt_Address.Clear();
                 txt_Email.Clear();
                 txt_Dept.Clear();
                 lv_Reader.Clear();
                 loadDocGia();
                 btn_Save.Enabled   = false;
                 btn_Cancel.Enabled = false;
             }
             else
             {
                 MessageBox.Show("Sửa độc giả không thành công!\nLỗi cơ sở dữ liệu", "Lỗi");
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Sửa không thành công!\nLưu ý có thể ban nhập sai kiểu dữ liệu!", "Lỗi");
         }
     }
 }
Пример #9
0
        //Sua
        public bool Update(DTO_DocGia dTO_DocGia)
        {
            try
            {
                cn.Open();
                //string SQL = string.Format("UPDATE ThuThu SET HoTen = '{0}', DiaChi = '{1}', SDT = '{2}', CMND = '{3}', NgaySinh = '{4}', NgayDK = '{5}' WHERE MaDocGia = '{6}'", dTO_DocGia.HoTen, dTO_DocGia.DiaChi, dTO_DocGia.SoDT, dTO_DocGia.Cmnd, dTO_DocGia.NgaySinh, dTO_DocGia.NgayDK, dTO_DocGia.MaDocGia);
                //SqlCommand cmd = new SqlCommand(SQL, cn);

                SqlCommand cmd = new SqlCommand("SuaDocGia", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter p = new SqlParameter("@MaDocGia", dTO_DocGia.MaDocGia);
                cmd.Parameters.Add(p);

                p = new SqlParameter("@HoTen", dTO_DocGia.HoTen);
                cmd.Parameters.Add(p);

                p = new SqlParameter("@DiaChi", dTO_DocGia.DiaChi);
                cmd.Parameters.Add(p);

                p = new SqlParameter("@CMND", dTO_DocGia.Cmnd);
                cmd.Parameters.Add(p);

                p = new SqlParameter("@SDT", dTO_DocGia.SoDT);
                cmd.Parameters.Add(p);

                p = new SqlParameter("@NgaySinh", dTO_DocGia.NgaySinh);
                cmd.Parameters.Add(p);

                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                cn.Close();
            }
            return(false);
        }
Пример #10
0
        public void CapNhatDocGia(DTO_DocGia DTO)
        {
            string strSql = "usp_CapNhatDocGia";

            DBConnect DBConnect = new DBConnect();

            DBConnect.Connect();

            DBConnect.ExecuteNonQuery(CommandType.StoredProcedure, strSql,
                                      new SqlParameter {
                ParameterName = "@MaDG", Value = DTO._maDG
            },
                                      new SqlParameter {
                ParameterName = "@TenDG", Value = DTO._tenDG
            },
                                      new SqlParameter {
                ParameterName = "@NgaySinhDG", Value = DTO._ngaySinh
            },
                                      new SqlParameter {
                ParameterName = "@DiaChiDG", Value = DTO._DiaChiDG
            },
                                      new SqlParameter {
                ParameterName = "@SDTDG", Value = DTO._SDT_DG
            },
                                      new SqlParameter {
                ParameterName = "@EmailDG", Value = DTO._email
            },
                                      new SqlParameter {
                ParameterName = "@CMNDDG", Value = DTO._CMND_DG
            },
                                      new SqlParameter {
                ParameterName = "@MSSVDG", Value = DTO._MSSV_DG
            },
                                      new SqlParameter {
                ParameterName = "@MCBDG", Value = DTO._MCB_DG
            },
                                      new SqlParameter {
                ParameterName = "@LoaiDG", Value = DTO._LoaiDG
            });
            DBConnect.Disconnect();
        }
Пример #11
0
        private bool InsertReader()
        {
            try
            {
                BUS_DocGia insertReader = new BUS_DocGia();

                int gioitinh = 1;
                if (radGTMale.Checked == false)
                {
                    gioitinh = 0;
                }

                DTO_DocGia dtoReader = new DTO_DocGia(0, txtReaderName.Text, int.Parse(txtNK.Text), gioitinh);
                insertReader.insertdocgia(dtoReader);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #12
0
        private bool UpdateReader()
        {
            try
            {
                BUS_DocGia updateAuthor = new BUS_DocGia();

                int gioitinh = 1;
                if (radGTMale.Checked == false)
                {
                    gioitinh = 0;
                }

                DTO_DocGia dtoReader = new DTO_DocGia(this.authorId, txtReaderName.Text, int.Parse(txtNK.Text), gioitinh);
                updateAuthor.updateDocGia(dtoReader);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #13
0
        //Them
        public bool Insert(DTO_DocGia dTO_DocGia)
        {
            try
            {
                cn.Open();
                string     SQL = string.Format("INSERT INTO ThuThu VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", dTO_DocGia.MaDocGia, dTO_DocGia.HoTen, dTO_DocGia.DiaChi, dTO_DocGia.SoDT, dTO_DocGia.Cmnd, dTO_DocGia.NgaySinh, dTO_DocGia.NgayDK);
                SqlCommand cmd = new SqlCommand(SQL, cn);


                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                cn.Close();
            }
            return(false);
        }
 public void CapNhatDocGia(DTO_DocGia DTO)
 {
     dal_DOcGia.CapNhatDocGia(DTO);
 }
 public bool ThemDocGia(DTO_DocGia DTO)
 {
     return(dal_DOcGia.ThemDocGia(DTO));
 }
Пример #16
0
 //public bool insertDocGia(string prvMaDocGia, string hoTen, string diaChi, string soDT, string cmnd, DateTime ngaySinh, DateTime ngayDK)
 //{
 //    int iMaDocGia;
 //    DataTable dt = dalDocGia.Get();
 //    return dalDocGia.Insert(dTO_DocGia);
 //}
 public bool updateDocGia(DTO_DocGia dTO_DocGia)
 {
     return(dalDocGia.Update(dTO_DocGia));
 }
Пример #17
0
 public bool insertdocgia(DTO_DocGia docgia)
 {
     return(daoTG.insertDocGia(docgia));
 }
Пример #18
0
 public bool updateDocGia(DTO_DocGia docgia)
 {
     return(daoTG.updateDocGia(docgia));
 }