public bool XoaChucDanh(string Id)
        {
            ChucDanhDTO ChucDanh = new ChucDanhDTO();

            ChucDanh.Id = int.Parse(Id);
            return(ChucDanhDAO.Instance.XoaChucDanh(ChucDanh));
        }
Beispiel #2
0
        public BindingList <ChucDanhDTO> LayDanhSach()
        {
            BindingList <ChucDanhDTO> danhSach = new BindingList <ChucDanhDTO>();
            OleDbConnection           cn;

            cn = DataProvider.KetNoi();
            string strSQL;

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

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

                itemDTO.Id          = (int)dr["Id"];
                itemDTO.MaChucDanh  = (string)dr["MaChucDanh"];
                itemDTO.TenChucDanh = (string)dr["TenChucDanh"];
                itemDTO.GhiChu      = (string)dr["GhiChu"];

                danhSach.Add(itemDTO);
            }
            return(danhSach);
        }
Beispiel #3
0
        public bool XoaChucDanh(ChucDanhDTO chucDanh)
        {
            string[] param  = { "@ID" };
            object[] values = { chucDanh.Id };
            string   query  = "Delete ChucDanh Where ID=@ID";

            return(DataProvider.Instance.ExecuteNonQueryPara(query, param, values));
        }
Beispiel #4
0
        public bool SuaChucDanh(ChucDanhDTO chucDanh)
        {
            string[] param  = { "@ID", "@Ten" };
            object[] values = { chucDanh.Id, chucDanh.Ten };
            string   query  = "Update ChucDanh Set Ten=@Ten Where ID=@ID";

            return(DataProvider.Instance.ExecuteNonQueryPara(query, param, values));
        }
Beispiel #5
0
        public bool ThemChucDanh(ChucDanhDTO chucDanh)
        {
            string[] param  = { "@Ten" };
            object[] values = { chucDanh.Ten };
            string   query  = "Insert Into ChucDanh Values(@Ten)";

            return(DataProvider.Instance.ExecuteNonQueryPara(query, param, values));
        }
        public bool ThemChucDanh(string TenChucDanh)
        {
            ChucDanhDTO ChucDanh = new ChucDanhDTO();

            try
            {
                ChucDanh.Ten = TenChucDanh;
            }
            catch (Exception)
            {
                return(false);
            }
            return(ChucDanhDAO.Instance.ThemChucDanh(ChucDanh));
        }
        public bool SuaChucDanh(string Id, string TenChucDanh)
        {
            ChucDanhDTO ChucDanh = new ChucDanhDTO();

            try
            {
                ChucDanh.Id  = int.Parse(Id);
                ChucDanh.Ten = TenChucDanh;
            }
            catch (Exception)
            {
                return(false);
            }
            return(ChucDanhDAO.Instance.SuaChucDanh(ChucDanh));
        }
Beispiel #8
0
        private void gvDanhMucChuDanh_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            if (gvDanhMucChuDanh.FocusedRowHandle > -1)
            {
                try
                {
                    ChucDanhDTO itemDTO = new ChucDanhDTO();
                    ChucDanhBUS itemBUS = new ChucDanhBUS();
                    itemDTO.MaChucDanh  = gvDanhMucChuDanh.GetFocusedRowCellValue("MaChucDanh").ToString();
                    itemDTO.TenChucDanh = gvDanhMucChuDanh.GetFocusedRowCellValue("TenChucDanh").ToString();
                    itemDTO.GhiChu      = gvDanhMucChuDanh.GetFocusedRowCellValue("GhiChu").ToString();
                    itemDTO.Id          = int.Parse(gvDanhMucChuDanh.GetFocusedRowCellValue("Id").ToString());

                    if (this.flagThem && gvDanhMucChuDanh.FocusedRowHandle == gvDanhMucChuDanh.RowCount - 2)
                    {
                        if (itemDTO.MaChucDanh.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.LayDanhSachChucDanh();
            }
        }
Beispiel #9
0
        /*
         * public BindingList<ChucDanhDTO> LayDanhSachCombobox()
         * {
         *  BindingList<ChucDanhDTO> danhSach = new BindingList<ChucDanhDTO>();
         *  OleDbConnection cn;
         *  cn = DataProvider.KetNoi();
         *  string strSQL;
         *  strSQL = "Select * From DanhMucChucDanh";
         *  OleDbCommand cmd = new OleDbCommand(strSQL, cn);
         *  OleDbDataReader dr;
         *  dr = cmd.ExecuteReader();
         *  while (dr.Read())
         *  {
         *      ChucDanhDTO itemDTO = new ChucDanhDTO();
         *
         *      itemDTO.Id = (int)dr["Id"];
         *      itemDTO.MaChucDanh = (string)dr["MaChucDanh"];
         *      itemDTO.TenChucDanh = (string)dr["TenChucDanh"];
         *      itemDTO.GhiChu = (string)dr["GhiChu"];
         *
         *      danhSach.Add(itemDTO);
         *  }
         *  return danhSach;
         * }
         */
        public void Them(ChucDanhDTO itemDTO)
        {
            OleDbConnection cn;

            cn = DataProvider.KetNoi();
            string strSQL;

            strSQL = "Insert into SysDanhMucChucDanh (MaChucDanh,TenChucDanh,GhiChu) values (?, ?, ?)";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);

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

            cmd.ExecuteNonQuery();

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

            cn = DataProvider.KetNoi();

            string strSQL;

            strSQL = "Update SysDanhMucChucDanh Set MaChucDanh = ?, TenChucDanh = ?, GhiChu = ? Where Id = ?";

            OleDbCommand cmd = new OleDbCommand(strSQL, cn);

            cmd.Parameters.Add("@MaChucDanh", OleDbType.WChar).Value  = itemDTO.MaChucDanh;
            cmd.Parameters.Add("@TenChucDanh", OleDbType.WChar).Value = itemDTO.TenChucDanh;
            cmd.Parameters.Add("@GhiChu", OleDbType.WChar).Value      = itemDTO.GhiChu;
            cmd.Parameters.Add("@Id", OleDbType.Numeric).Value        = itemDTO.Id;

            cmd.ExecuteNonQuery();
            cn.Close();
        }
Beispiel #11
0
        public void Sua(ChucDanhDTO itemDTO)
        {
            ChucDanhDAO itemDAO = new ChucDanhDAO();

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

            itemDAO.Them(itemDTO);
        }