示例#1
0
        private void btnHieuChinh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            vitri             = bdsLop.Position;
            groupBox1.Enabled = true;
            btnThem.Enabled   = btnHieuChinh.Enabled = btnXoa.Enabled = btnPhucHoi.Enabled = btnThoat.Enabled = false;
            btnGhi.Enabled    = btnPhucHoi.Enabled = true;
            txtMaLop.Enabled  = txtMaKhoa.Enabled = false;
            gcLop.Enabled     = false;
            choose            = HIEU_CHINH;

            Lop     lop  = new Lop(txtMaLop.Text, txtTenLop.Text, txtMaKhoa.Text);
            UndoLop undo = new UndoLop(HIEU_CHINH, lop);

            st.Push(undo);

            capNhatBtnPhucHoi();
        }
示例#2
0
        private void btnPhucHoi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (isDangThem)
            {
                reload();
                capNhatBtnPhucHoi();
                isDangThem = false;
            }

            bdsLop.CancelEdit();
            if (btnThem.Enabled == false)
            {
                bdsLop.Position = vitri;
            }
            gcLop.Enabled     = true;
            groupBox1.Enabled = false;
            btnThem.Enabled   = btnHieuChinh.Enabled = btnXoa.Enabled = btnThoat.Enabled = true;
            btnGhi.Enabled    = btnPhucHoi.Enabled = false;

            if (st.Count == 0)
            {
                return;
            }

            UndoLop objUndo = (UndoLop)st.Pop();
            Object  obj     = objUndo.obj;

            switch (objUndo.chucNang)
            {
            case THEM:
                Program.ExecSqlDataReader(obj.ToString());
                this.LopTableAdapter.Fill(this.DS.LOP);
                capNhatBtnPhucHoi();
                break;

            case HIEU_CHINH:
                Lop lopHieuChinh = (Lop)obj;
                if (Program.conn.State == ConnectionState.Closed)
                {
                    Program.conn.Open();
                }

                String sqlHieuChinh = "exec sp_PhucHoiLopHieuChinh N'" + lopHieuChinh.maLop + "',N'" + lopHieuChinh.tenLop + "'";
                Program.ExecSqlDataTable(sqlHieuChinh);

                //String strPhucHoiHieuChinh = "sp_PhucHoiLopHieuChinh";
                //Program.sqlcmd = Program.conn.CreateCommand();
                //Program.sqlcmd.CommandType = CommandType.StoredProcedure;
                //Program.sqlcmd.CommandText = strPhucHoiHieuChinh;
                //Program.sqlcmd.Parameters.Add("@MALOP", SqlDbType.Text).Value = lopHieuChinh.maLop;
                //Program.sqlcmd.Parameters.Add("@TENLOP", SqlDbType.Text).Value = lopHieuChinh.tenLop;
                //Program.sqlcmd.ExecuteNonQuery();
                Program.conn.Close();
                reload();
                break;

            case XOA:
                Lop lopXoa = (Lop)obj;
                if (Program.conn.State == ConnectionState.Closed)
                {
                    Program.conn.Open();
                }

                String sql = "exec sp_ThemLop N'" + lopXoa + "',N'" + lopXoa.tenLop + "',N'" + lopXoa.maKhoa + "'";
                Program.ExecSqlDataTable(sql);

                //String strPhucHoiXoa = "sp_ThemLop";
                //Program.sqlcmd = Program.conn.CreateCommand();
                //Program.sqlcmd.CommandType = CommandType.StoredProcedure;
                //Program.sqlcmd.CommandText = strPhucHoiXoa;
                //Program.sqlcmd.Parameters.Add("@MALOP", SqlDbType.Text).Value = lopXoa.maLop;
                //Program.sqlcmd.Parameters.Add("@TENLOP", SqlDbType.Text).Value = lopXoa.tenLop;
                //Program.sqlcmd.Parameters.Add("@MAKHOA", SqlDbType.Text).Value = lopXoa.maKhoa;
                //Program.sqlcmd.ExecuteNonQuery();
                reload();
                break;
            }
        }