コード例 #1
0
 private void RaiseItemSelectedEventHander(DIC_SCHOOL item)
 {
     if (this.ItemSelected != null)
     {
         this.ItemSelected(this, item);
     }
 }
コード例 #2
0
 public void RaiseUpdatedEventHander(DIC_SCHOOL Item)
 {
     if (this.Updated != null)
     {
         this.Updated(this, Item);
     }
 }
コード例 #3
0
        protected override string uc_Update()
        {
            string str;

            if (MyRule.Get(MyLogin.RoleId, "bbiSchool") != "OK")
            {
                str = "";
            }
            else if (MyRule.AllowEdit)
            {
                // SYS_LOG.Insert("Danh Mục Trường Học", "Cập Nhật", this.txtID.Text);
                base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
                DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked);
                string     str1      = dICSCHOOL.Update();
                if (str1 == "OK")
                {
                    this.RaiseSuccessEventHander(dICSCHOOL);
                }
                if (str1 != "OK")
                {
                    XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.DoHide();
                str = str1;
            }
            else
            {
                MyRule.Notify();
                str = "";
            }
            return(str);
        }
コード例 #4
0
 private void RaiseSuccessEventHander(DIC_SCHOOL item)
 {
     if (this.Success != null)
     {
         this.Success(this, item);
     }
 }
コード例 #5
0
 public override void Change()
 {
     if (!(MyRule.Get(MyLogin.RoleId, "bbiSchool") != "OK"))
     {
         if (MyRule.AllowAccess)
         {
             DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL();
             object     cellValue = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "SchoolCode");
             if (cellValue != null)
             {
                 base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                 if (!(dICSCHOOL.Get(cellValue.ToString()) != "OK"))
                 {
                     this.DoHide();
                     xfmSchoolAdd _xfmSchoolAdd = new xfmSchoolAdd(Actions.Update, dICSCHOOL);
                     _xfmSchoolAdd.Updated += new xfmSchoolAdd.UpdatedEventHander(this.frm_Updated);
                     _xfmSchoolAdd.Added   += new xfmSchoolAdd.AddedEventHander(this.frm_Added);
                     _xfmSchoolAdd.ShowDialog();
                 }
                 else
                 {
                     this.DoHide();
                     XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
         else
         {
             MyRule.Notify();
         }
     }
 }
コード例 #6
0
        protected override void Add()
        {
            base.Add();
            DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL();

            this.txtID.Text = dICSCHOOL.NewID();
            this.txtNAME.Focus();
        }
コード例 #7
0
        public xfmSchoolAdd(Actions Action)
        {
            this.InitializeComponent();
            this.Init();
            this.ucAdd.Status = Action;
            DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL();

            this.ucAdd.SetData(dICSCHOOL.NewID());
            this.Text = "Thêm";
        }
コード例 #8
0
        private void UpdateRow(DIC_SCHOOL item, RowClickEventArgs e)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int rowIndex = e.RowIndex;

            advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active);
            advBandedGridView.SetRowCellValue(rowIndex, "SchoolCode", item.SchoolCode);
            advBandedGridView.SetRowCellValue(rowIndex, "SchoolName", item.SchoolName);
            advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description);
            advBandedGridView.UpdateCurrentRow();
            this.RaiseUpdatedEventHander(item);
        }
コード例 #9
0
 public void SetData(DIC_SCHOOL item)
 {
     this.txtID.Text = item.SchoolCode;
     //  SYS_LOG.Insert("Danh Mục Trường Học", "Xem", this.txtID.Text);
     if (this.m_Status == Actions.Update)
     {
         this.txtID.Properties.ReadOnly = true;
     }
     this.txtNAME.Text        = item.SchoolName;
     this.txtDescription.Text = item.Description;
     this.chxUse.Checked      = item.Active;
 }
コード例 #10
0
        private void AddRow(DIC_SCHOOL Item)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int focusedRowHandle = advBandedGridView.FocusedRowHandle;

            advBandedGridView.AddNewRow();
            focusedRowHandle = advBandedGridView.FocusedRowHandle;
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "SchoolCode", Item.SchoolCode);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "SchoolName", Item.SchoolName);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description);
            advBandedGridView.UpdateCurrentRow();
            this.RaiseAddedEventHander(Item);
        }
コード例 #11
0
        protected override string uc_Delete()
        {
            DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL()
            {
                SchoolCode = this.txtID.Text
            };
            string str = dICSCHOOL.Delete();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICSCHOOL);
            }
            return(str);
        }
コード例 #12
0
 public xfmSchoolAdd(Actions Action, DIC_SCHOOL Item)
 {
     this.InitializeComponent();
     this.Init();
     this.ucAdd.Status = Action;
     if (Action == Actions.Update)
     {
         this.ucAdd.SetData(Item);
         this.Text = "Cập nhật";
     }
     else if (Action == Actions.Delete)
     {
         this.ucAdd.SetData(Item.SchoolCode);
     }
 }
コード例 #13
0
 private void ucAdd_Success(object sender, DIC_SCHOOL Item)
 {
     if (this.ucAdd.Status == Actions.Add)
     {
         this.RaiseAddedEventHander(Item);
     }
     else if (this.ucAdd.Status == Actions.Update)
     {
         this.RaiseUpdatedEventHander(Item);
     }
     if (this.ucAdd.IsClose == CloseOrNew.Close)
     {
         base.Close();
     }
     this.ucAdd.Clear();
 }
コード例 #14
0
ファイル: DAO_DIC_SCHOOL.cs プロジェクト: ds-v-bui/tho
        public static DIC_SCHOOL Select_Record(DIC_SCHOOL clsDIC_SCHOOLPara)
        {
            DIC_SCHOOL    clsDIC_SCHOOL = new DIC_SCHOOL();
            SqlConnection connection    = DAO_BASE.Get_Connection();
            string        selectStatement
                = "SELECT "
                  + "     [SchoolCode] "
                  + "    ,[SchoolName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "FROM "
                  + "     [DIC_SCHOOL] "
                  + "WHERE "
                  + "     [SchoolCode] = @SchoolCode "
                  + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.CommandType = CommandType.Text;
            selectCommand.Parameters.AddWithValue("@SchoolCode", clsDIC_SCHOOLPara.SchoolCode);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    clsDIC_SCHOOL.SchoolCode  = System.Convert.ToString(reader["SchoolCode"]);
                    clsDIC_SCHOOL.SchoolName  = reader["SchoolName"] is DBNull ? null : reader["SchoolName"].ToString();
                    clsDIC_SCHOOL.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString();
                    clsDIC_SCHOOL.Active      = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"];
                }
                else
                {
                    clsDIC_SCHOOL = null;
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(clsDIC_SCHOOL);
        }
コード例 #15
0
        protected override void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            TextEdit textEdit = (TextEdit)sender;

            if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab)
            {
                DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL();
                if (this.m_Status == Actions.Add)
                {
                    if (dICSCHOOL.Exist(textEdit.Text))
                    {
                        this.Err.SetError(textEdit, "Mã đã tồn tại.");
                        textEdit.Focus();
                    }
                }
            }
        }
コード例 #16
0
        public override void ReLoad()
        {
            base.SetWaitDialogCaption("Đang nạp dữ liệu...");
            DIC_SCHOOL dICSCHOOL = new DIC_SCHOOL();

            this.gcList.DataSource = dICSCHOOL.GetList();
            base.SetWaitDialogCaption("Đang nạp cấu hình...");
            this.List_Init(this.gbList);
            base.SetWaitDialogCaption("Nạp quyền sử dụng...");
            MyRule.Get(MyLogin.RoleId, "bbiSchool");
            if (!MyRule.AllowPrint)
            {
                this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiSchool");
            if (!MyRule.AllowExport)
            {
                this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiSchool");
            if (!MyRule.AllowAdd)
            {
                this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiSchool");
            if (!MyRule.AllowDelete)
            {
                this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiSchool");
            if (!MyRule.AllowEdit)
            {
                this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never;
            }
            base.SetWaitDialogCaption("Đã xong...");
            this.DoHide();
        }
コード例 #17
0
ファイル: DAO_DIC_SCHOOL.cs プロジェクト: ds-v-bui/tho
        public static bool Delete(DIC_SCHOOL clsDIC_SCHOOL)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        deleteStatement
                = "DELETE FROM "
                  + "     [DIC_SCHOOL] "
                  + "WHERE "
                  + "     [SchoolCode] = @OldSchoolCode "
                  + " AND ((@OldSchoolName IS NULL AND [SchoolName] IS NULL) OR [SchoolName] = @OldSchoolName) "
                  + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) "
                  + " AND ((@OldActive IS NULL AND [Active] IS NULL) OR [Active] = @OldActive) "
                  + "";
            SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

            deleteCommand.CommandType = CommandType.Text;
            deleteCommand.Parameters.AddWithValue("@OldSchoolCode", clsDIC_SCHOOL.SchoolCode);
            if (clsDIC_SCHOOL.SchoolName != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldSchoolName", clsDIC_SCHOOL.SchoolName);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldSchoolName", DBNull.Value);
            }
            if (clsDIC_SCHOOL.Description != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_SCHOOL.Description);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (clsDIC_SCHOOL.Active.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_SCHOOL.Active);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = deleteCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #18
0
ファイル: DAO_DIC_SCHOOL.cs プロジェクト: ds-v-bui/tho
        public static bool Add(DIC_SCHOOL clsDIC_SCHOOL)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        insertStatement
                = "INSERT "
                  + "     [DIC_SCHOOL] "
                  + "     ( "
                  + "     [SchoolCode] "
                  + "    ,[SchoolName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "     ) "
                  + "VALUES "
                  + "     ( "
                  + "     @SchoolCode "
                  + "    ,@SchoolName "
                  + "    ,@Description "
                  + "    ,@Active "
                  + "     ) "
                  + "";
            SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

            insertCommand.CommandType = CommandType.Text;
            insertCommand.Parameters.AddWithValue("@SchoolCode", clsDIC_SCHOOL.SchoolCode);
            if (clsDIC_SCHOOL.SchoolName != null)
            {
                insertCommand.Parameters.AddWithValue("@SchoolName", clsDIC_SCHOOL.SchoolName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@SchoolName", DBNull.Value);
            }
            if (clsDIC_SCHOOL.Description != null)
            {
                insertCommand.Parameters.AddWithValue("@Description", clsDIC_SCHOOL.Description);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Description", DBNull.Value);
            }
            if (clsDIC_SCHOOL.Active.HasValue == true)
            {
                insertCommand.Parameters.AddWithValue("@Active", clsDIC_SCHOOL.Active);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Active", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = insertCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #19
0
 private void ucList_Updated(object sender, DIC_SCHOOL Item)
 {
     this.RaiseUpdatedEventHander(Item);
 }
コード例 #20
0
 private void frm_Added(object sender, DIC_SCHOOL e)
 {
     this.AddRow(e);
 }
コード例 #21
0
 private void frm_Updated(object sender, DIC_SCHOOL Item)
 {
     this.UpdateRow(Item, this.m_RowClickEventArgs);
 }
コード例 #22
0
        public override void Delete()
        {
            object cellValue;

            if (!(MyRule.Get(MyLogin.RoleId, "bbiSchool") != "OK"))
            {
                if (MyRule.AllowDelete)
                {
                    if (ClsOption.System2.IsQuestion)
                    {
                        if (XtraMessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                    }
                    base.SetWaitDialogCaption("Đang xóa...");
                    string            str  = "";
                    bool              flag = false;
                    AdvBandedGridView advBandedGridView = this.gbList;
                    int[]             selectedRows      = advBandedGridView.GetSelectedRows();
                    DIC_SCHOOL        dICSCHOOL         = new DIC_SCHOOL();
                    for (int i = (int)selectedRows.Length; i > 0; i--)
                    {
                        flag      = true;
                        cellValue = base.GetCellValue(selectedRows[i - 1], "SchoolCode");
                        if (cellValue != null)
                        {
                            // SYS_LOG.Insert("Danh Mục Trường Học", "Xoá", cellValue.ToString());
                            str = dICSCHOOL.Delete(cellValue.ToString());
                            if (str == "OK")
                            {
                                advBandedGridView.DeleteRow(selectedRows[i - 1]);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show(string.Concat("Thông tin không được xóa\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                        }
                    }
                    this.DoHide();
                    if (!flag)
                    {
                        if (advBandedGridView.DataSource != null)
                        {
                            RowClickEventArgs rowClickEventArg = new RowClickEventArgs((advBandedGridView == null ? -1 : advBandedGridView.FocusedRowHandle), (advBandedGridView.FocusedColumn == null ? -1 : advBandedGridView.FocusedColumn.ColumnHandle), (advBandedGridView.FocusedColumn == null ? "" : advBandedGridView.FocusedColumn.FieldName));
                            this.m_RowClickEventArgs = rowClickEventArg;
                            cellValue = null;
                            cellValue = base.GetCellValue(rowClickEventArg.RowIndex, "SchoolCode");
                            if (cellValue == null)
                            {
                                return;
                            }
                            //  SYS_LOG.Insert("Danh Mục Trường Học", "Xoá", cellValue.ToString());
                            base.SetWaitDialogCaption("Đang xóa...");
                            str = dICSCHOOL.Delete(cellValue.ToString());
                            if (str == "OK")
                            {
                                advBandedGridView.DeleteRow(rowClickEventArg.RowIndex);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show(string.Concat("Thông tin không được xóa\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                            this.DoHide();
                        }
                        else
                        {
                            return;
                        }
                    }
                    this.RaiseDeletedEventHander();
                }
                else
                {
                    MyRule.Notify();
                }
            }
        }
コード例 #23
0
ファイル: DAO_DIC_SCHOOL.cs プロジェクト: ds-v-bui/tho
        public static bool Update(DIC_SCHOOL oldDIC_SCHOOL,
                                  DIC_SCHOOL newDIC_SCHOOL)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        updateStatement
                = "UPDATE "
                  + "     [DIC_SCHOOL] "
                  + "SET "
                  + "     [SchoolCode] = @NewSchoolCode "
                  + "    ,[SchoolName] = @NewSchoolName "
                  + "    ,[Description] = @NewDescription "
                  + "    ,[Active] = @NewActive "
                  + "WHERE "
                  + "     [SchoolCode] = @OldSchoolCode "
                  + " AND ((@OldSchoolName IS NULL AND [SchoolName] IS NULL) OR [SchoolName] = @OldSchoolName) "
                  + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) "
                  + " AND ((@OldActive IS NULL AND [Active] IS NULL) OR [Active] = @OldActive) "
                  + "";
            SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

            updateCommand.CommandType = CommandType.Text;
            updateCommand.Parameters.AddWithValue("@NewSchoolCode", newDIC_SCHOOL.SchoolCode);
            if (newDIC_SCHOOL.SchoolName != null)
            {
                updateCommand.Parameters.AddWithValue("@NewSchoolName", newDIC_SCHOOL.SchoolName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewSchoolName", DBNull.Value);
            }
            if (newDIC_SCHOOL.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_SCHOOL.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value);
            }
            if (newDIC_SCHOOL.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@NewActive", newDIC_SCHOOL.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value);
            }
            updateCommand.Parameters.AddWithValue("@OldSchoolCode", oldDIC_SCHOOL.SchoolCode);
            if (oldDIC_SCHOOL.SchoolName != null)
            {
                updateCommand.Parameters.AddWithValue("@OldSchoolName", oldDIC_SCHOOL.SchoolName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldSchoolName", DBNull.Value);
            }
            if (oldDIC_SCHOOL.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_SCHOOL.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (oldDIC_SCHOOL.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_SCHOOL.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldActive", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = updateCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }