Beispiel #1
0
        public BindingList <HoatChatChinhDTO> LayDanhSach()
        {
            BindingList <HoatChatChinhDTO> danhSach = new BindingList <HoatChatChinhDTO>();
            OleDbConnection cn;

            cn = DataProvider.KetNoi();
            string strSQL;

            strSQL = "Select * From DanhMucHoatChatChinh";
            OleDbCommand    cmd = new OleDbCommand(strSQL, cn);
            OleDbDataReader dr;

            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                HoatChatChinhDTO itemDTO = new HoatChatChinhDTO();

                itemDTO.Id = (int)dr["Id"];
                itemDTO.MaHoatChatChinh  = (string)dr["MaHoatChatChinh"];
                itemDTO.TenHoatChatChinh = (string)dr["TenHoatChatChinh"];
                itemDTO.GhiChu           = (string)dr["GhiChu"];

                danhSach.Add(itemDTO);
            }
            return(danhSach);
        }
Beispiel #2
0
        public void Them(HoatChatChinhDTO itemDTO)
        {
            OleDbConnection cn;
            cn = DataProvider.KetNoi();
            string strSQL;

            strSQL = "Insert into DanhMucHoatChatChinh (MaHoatChatChinh,TenHoatChatChinh,GhiChu) values (?, ?, ?)";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);

            cmd.Parameters.Add("@MaHoatChatChinh", OleDbType.WChar).Value = itemDTO.MaHoatChatChinh;
            cmd.Parameters.Add("@TenHoatChatChinh", OleDbType.WChar).Value = itemDTO.TenHoatChatChinh;
            cmd.Parameters.Add("@GhiChu", OleDbType.WChar).Value = itemDTO.GhiChu;

                cmd.ExecuteNonQuery();

            cn.Close();
        }
Beispiel #3
0
        public void Sua(HoatChatChinhDTO itemDTO)
        {
            OleDbConnection cn;
            cn = DataProvider.KetNoi();

            string strSQL;
            strSQL = "Update DanhMucHoatChatChinh Set MaHoatChatChinh = ?, TenHoatChatChinh = ?, GhiChu = ? Where Id = ?";

            OleDbCommand cmd = new OleDbCommand(strSQL, cn);
            cmd.Parameters.Add("@MaBacSy", OleDbType.WChar).Value = itemDTO.MaHoatChatChinh;
            cmd.Parameters.Add("@TenBacSy", OleDbType.WChar).Value = itemDTO.TenHoatChatChinh;
            cmd.Parameters.Add("@GhiChu", OleDbType.WChar).Value = itemDTO.GhiChu;
            cmd.Parameters.Add("@Id", OleDbType.Numeric).Value = itemDTO.Id;

            cmd.ExecuteNonQuery();
            cn.Close();
        }
        private void gvDanhMucHoatChatChinh_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            if (gvDanhMucHoatChatChinh.FocusedRowHandle > -1)
            {
                try
                {
                    HoatChatChinhDTO itemDTO = new HoatChatChinhDTO();
                    HoatChatChinhBUS itemBUS = new HoatChatChinhBUS();
                    itemDTO.MaHoatChatChinh  = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("MaHoatChatChinh").ToString();
                    itemDTO.TenHoatChatChinh = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("TenHoatChatChinh").ToString();
                    itemDTO.GhiChu           = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("GhiChu").ToString();
                    itemDTO.Id = int.Parse(gvDanhMucHoatChatChinh.GetFocusedRowCellValue("Id").ToString());

                    if (this.flagThem && gvDanhMucHoatChatChinh.FocusedRowHandle == gvDanhMucHoatChatChinh.RowCount - 2)
                    {
                        if (itemDTO.MaHoatChatChinh.Length > 0)
                        {
                            DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn thêm mới?", "Thêm mới", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (hopThoai == DialogResult.Yes)
                            {
                                itemBUS.Them(itemDTO);
                                this.flagThem = false;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Bạn chưa nhập mã!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn cập nhật?", "Cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (hopThoai == DialogResult.Yes)
                        {
                            itemBUS.Sua(itemDTO);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                this.LayDanhSachHoatChatChinh();
            }
        }
        private void gvDanhMucHoatChatChinh_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            if (gvDanhMucHoatChatChinh.FocusedRowHandle > -1)
            {
                try
                {
                    HoatChatChinhDTO itemDTO = new HoatChatChinhDTO();
                    HoatChatChinhBUS itemBUS = new HoatChatChinhBUS();
                    itemDTO.MaHoatChatChinh = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("MaHoatChatChinh").ToString();
                    itemDTO.TenHoatChatChinh = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("TenHoatChatChinh").ToString();
                    itemDTO.GhiChu = gvDanhMucHoatChatChinh.GetFocusedRowCellValue("GhiChu").ToString();
                    itemDTO.Id = int.Parse(gvDanhMucHoatChatChinh.GetFocusedRowCellValue("Id").ToString());

                    if (this.flagThem && gvDanhMucHoatChatChinh.FocusedRowHandle == gvDanhMucHoatChatChinh.RowCount - 2)
                    {
                        if (itemDTO.MaHoatChatChinh.Length > 0)
                        {
                            DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn thêm mới?", "Thêm mới", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (hopThoai == DialogResult.Yes)
                            {
                                itemBUS.Them(itemDTO);
                                this.flagThem = false;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Bạn chưa nhập mã!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn cập nhật?", "Cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (hopThoai == DialogResult.Yes)
                        {
                            itemBUS.Sua(itemDTO);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                this.LayDanhSachHoatChatChinh();
            }
        }
Beispiel #6
0
        public void Them(HoatChatChinhDTO itemDTO)
        {
            OleDbConnection cn;

            cn = DataProvider.KetNoi();
            string strSQL;

            strSQL = "Insert into DanhMucHoatChatChinh (MaHoatChatChinh,TenHoatChatChinh,GhiChu) values (?, ?, ?)";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);

            cmd.Parameters.Add("@MaHoatChatChinh", OleDbType.WChar).Value  = itemDTO.MaHoatChatChinh;
            cmd.Parameters.Add("@TenHoatChatChinh", OleDbType.WChar).Value = itemDTO.TenHoatChatChinh;
            cmd.Parameters.Add("@GhiChu", OleDbType.WChar).Value           = itemDTO.GhiChu;

            cmd.ExecuteNonQuery();

            cn.Close();
        }
Beispiel #7
0
        public void Sua(HoatChatChinhDTO itemDTO)
        {
            OleDbConnection cn;

            cn = DataProvider.KetNoi();

            string strSQL;

            strSQL = "Update DanhMucHoatChatChinh Set MaHoatChatChinh = ?, TenHoatChatChinh = ?, GhiChu = ? Where Id = ?";

            OleDbCommand cmd = new OleDbCommand(strSQL, cn);

            cmd.Parameters.Add("@MaBacSy", OleDbType.WChar).Value  = itemDTO.MaHoatChatChinh;
            cmd.Parameters.Add("@TenBacSy", OleDbType.WChar).Value = itemDTO.TenHoatChatChinh;
            cmd.Parameters.Add("@GhiChu", OleDbType.WChar).Value   = itemDTO.GhiChu;
            cmd.Parameters.Add("@Id", OleDbType.Numeric).Value     = itemDTO.Id;

            cmd.ExecuteNonQuery();
            cn.Close();
        }
Beispiel #8
0
        public BindingList<HoatChatChinhDTO> LayDanhSach()
        {
            BindingList<HoatChatChinhDTO> danhSach = new BindingList<HoatChatChinhDTO>();
            OleDbConnection cn;
            cn = DataProvider.KetNoi();
            string strSQL;
            strSQL = "Select * From DanhMucHoatChatChinh";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);
            OleDbDataReader dr;
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                HoatChatChinhDTO itemDTO = new HoatChatChinhDTO();

                itemDTO.Id = (int)dr["Id"];
                itemDTO.MaHoatChatChinh = (string)dr["MaHoatChatChinh"];
                itemDTO.TenHoatChatChinh = (string)dr["TenHoatChatChinh"];
                itemDTO.GhiChu = (string)dr["GhiChu"];

                danhSach.Add(itemDTO);
            }
            return danhSach;
        }
Beispiel #9
0
 public void Them(HoatChatChinhDTO itemDTO)
 {
     HoatChatChinhDAO itemDAO = new HoatChatChinhDAO();
     itemDAO.Them(itemDTO);
 }
Beispiel #10
0
 public void Sua(HoatChatChinhDTO itemDTO)
 {
     HoatChatChinhDAO itemDAO = new HoatChatChinhDAO();
     itemDAO.Sua(itemDTO);
 }
Beispiel #11
0
        public void Sua(HoatChatChinhDTO itemDTO)
        {
            HoatChatChinhDAO itemDAO = new HoatChatChinhDAO();

            itemDAO.Sua(itemDTO);
        }
Beispiel #12
0
        public void Them(HoatChatChinhDTO itemDTO)
        {
            HoatChatChinhDAO itemDAO = new HoatChatChinhDAO();

            itemDAO.Them(itemDTO);
        }