public override void Change() { if (!(MyRule.Get(MyLogin.RoleId, "bbiEducation") != "OK")) { if (MyRule.AllowAccess) { DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(); object cellValue = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "EducationCode"); if (cellValue != null) { base.SetWaitDialogCaption("Đang kiểm tra dữ liệu...."); if (!(dICEDUCATION.Get(cellValue.ToString()) != "OK")) { this.DoHide(); xfmEducationAdd _xfmEducationAdd = new xfmEducationAdd(Actions.Update, dICEDUCATION); _xfmEducationAdd.Updated += new xfmEducationAdd.UpdatedEventHander(this.frm_Updated); _xfmEducationAdd.Added += new xfmEducationAdd.AddedEventHander(this.frm_Added); _xfmEducationAdd.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(); } } }
protected override string uc_Update() { string str; if (MyRule.Get(MyLogin.RoleId, "bbiEducation") != "OK") { str = ""; } else if (MyRule.AllowEdit) { // SYS_LOG.Insert("Danh Mục Học Vấn", "Cập Nhật", this.txtID.Text); base.SetWaitDialogCaption("Đang cập nhật dữ liệu..."); DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked); string str1 = dICEDUCATION.Update(); if (str1 == "OK") { this.RaiseSuccessEventHander(dICEDUCATION); } if (str1 != "OK") { XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.DoHide(); str = str1; } else { MyRule.Notify(); str = ""; } return(str); }
public void RaiseUpdatedEventHander(DIC_EDUCATION Item) { if (this.Updated != null) { this.Updated(this, Item); } }
private void RaiseItemSelectedEventHander(DIC_EDUCATION item) { if (this.ItemSelected != null) { this.ItemSelected(this, item); } }
private void RaiseSuccessEventHander(DIC_EDUCATION item) { if (this.Success != null) { this.Success(this, item); } }
public static ENT_RETURN Check_Data(DIC_EDUCATION e) { ENT_RETURN ret = new ENT_RETURN(); string err_msg = string.Empty; // BEGIN CHECK if (Is_Empty_String(e.EducationName)) { err_msg += GLOBAL.err_code["E006"]; } if (Is_Over_MaxLength(e.EducationName, 100)) { err_msg += GLOBAL.err_code["E007"]; } if (Is_Over_MaxLength(e.Description, 255)) { err_msg += GLOBAL.err_code["E003"]; } // END CHECK if (err_msg != string.Empty) { ret.Message = err_msg; ret.Status = false; } return(ret); }
private bool Insert() { new_entity = new DIC_EDUCATION(); new_entity.EducationCode = txt_EDUCATION_CODE.Text; new_entity.EducationName = txt_EDUCATION_NAME.Text; new_entity.Description = txt_DESCRIPTION.Text; //new_entity.IsManager = chk_IS_MANAGER.Checked; new_entity.Active = true; ENT_RETURN validate = LOGIC_CHECK.Check_Data(new_entity); if (validate.Status) { DAO_DIC_EDUCATION.Add(new_entity); if (parent != null) { parent.dg_DATA.DataSource = DAO_DIC_EDUCATION.Get_Data(); } } else { XtraMessageBox.Show(validate.Message, "Lỗi !!"); return(false); } return(true); }
protected override void Add() { base.Add(); DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(); this.txtID.Text = dICEDUCATION.NewID(); this.txtNAME.Focus(); }
public xfmEducationAdd(Actions Action) { this.InitializeComponent(); this.Init(); this.ucAdd.Status = Action; DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(); this.ucAdd.SetData(dICEDUCATION.NewID()); this.Text = "Thêm"; }
private void UpdateRow(DIC_EDUCATION item, RowClickEventArgs e) { AdvBandedGridView advBandedGridView = this.gbList; int rowIndex = e.RowIndex; advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active); advBandedGridView.SetRowCellValue(rowIndex, "EducationCode", item.EducationCode); advBandedGridView.SetRowCellValue(rowIndex, "EducationName", item.EducationName); advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description); advBandedGridView.UpdateCurrentRow(); }
public void SetData(DIC_EDUCATION item) { this.txtID.Text = item.EducationCode; // SYS_LOG.Insert("Danh Mục Học Vấn", "Xem", this.txtID.Text); if (this.m_Status == Actions.Update) { this.txtID.Properties.ReadOnly = true; } this.txtNAME.Text = item.EducationName; this.txtDescription.Text = item.Description; this.chxUse.Checked = item.Active; }
private void frm_EDIT_Load(object sender, EventArgs e) { old_entity = new DIC_EDUCATION(); old_entity.EducationCode = CODE; old_entity = DAO_DIC_EDUCATION.Select_Record(old_entity); txt_EDUCATION_CODE.Text = old_entity.EducationCode; txt_EDUCATION_NAME.Text = old_entity.EducationName; txt_DESCRIPTION.Text = old_entity.Description; }
private void AddRow(DIC_EDUCATION Item) { AdvBandedGridView advBandedGridView = this.gbList; int focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.AddNewRow(); focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active); advBandedGridView.SetRowCellValue(focusedRowHandle, "EducationCode", Item.EducationCode); advBandedGridView.SetRowCellValue(focusedRowHandle, "EducationName", Item.EducationName); advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description); advBandedGridView.UpdateCurrentRow(); }
protected override string uc_Delete() { DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION() { EducationCode = this.txtID.Text }; string str = dICEDUCATION.Delete(); if (str == "OK") { this.RaiseSuccessEventHander(dICEDUCATION); } return(str); }
public xfmEducationAdd(Actions Action, DIC_EDUCATION 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.EducationCode); } }
private void ucAdd_Success(object sender, DIC_EDUCATION 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(); }
public static DIC_EDUCATION Select_Record(DIC_EDUCATION clsDIC_EDUCATIONPara) { DIC_EDUCATION clsDIC_EDUCATION = new DIC_EDUCATION(); SqlConnection connection = DAO_BASE.Get_Connection(); string selectStatement = "SELECT " + " [EducationCode] " + " ,[EducationName] " + " ,[Description] " + " ,[Active] " + "FROM " + " [DIC_EDUCATION] " + "WHERE " + " [EducationCode] = @EducationCode " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@EducationCode", clsDIC_EDUCATIONPara.EducationCode); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsDIC_EDUCATION.EducationCode = System.Convert.ToString(reader["EducationCode"]); clsDIC_EDUCATION.EducationName = reader["EducationName"] is DBNull ? null : reader["EducationName"].ToString(); clsDIC_EDUCATION.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString(); clsDIC_EDUCATION.Active = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"]; } else { clsDIC_EDUCATION = null; } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return(clsDIC_EDUCATION); }
protected override void txtID_KeyDown(object sender, KeyEventArgs e) { TextEdit textEdit = (TextEdit)sender; if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab) { DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(); if (this.m_Status == Actions.Add) { if (dICEDUCATION.Exist(textEdit.Text)) { this.Err.SetError(textEdit, "Mã đã tồn tại."); textEdit.Focus(); } } } }
private void btn_SAVE_Click(object sender, EventArgs e) { new_entity = new DIC_EDUCATION(); new_entity.EducationCode = txt_EDUCATION_CODE.Text; new_entity.EducationName = txt_EDUCATION_NAME.Text; new_entity.Description = txt_DESCRIPTION.Text; new_entity.Active = old_entity.Active; ENT_RETURN validate = LOGIC_CHECK.Check_Data(new_entity); if (validate.Status) { DAO_DIC_EDUCATION.Update(old_entity, new_entity); this.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show(validate.Message, "Lỗi !!"); } this.DialogResult = DialogResult.OK; }
public override void ReLoad() { base.SetWaitDialogCaption("Đang nạp dữ liệu..."); DIC_EDUCATION dICEDUCATION = new DIC_EDUCATION(); this.gcList.DataSource = dICEDUCATION.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, "bbiEducation"); if (!MyRule.AllowPrint) { this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiEducation"); if (!MyRule.AllowExport) { this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiEducation"); if (!MyRule.AllowAdd) { this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiEducation"); if (!MyRule.AllowDelete) { this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiEducation"); if (!MyRule.AllowEdit) { this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never; } base.SetWaitDialogCaption("Đã xong..."); this.DoHide(); }
public static bool Add(DIC_EDUCATION clsDIC_EDUCATION) { SqlConnection connection = DAO_BASE.Get_Connection(); string insertStatement = "INSERT " + " [DIC_EDUCATION] " + " ( " + " [EducationCode] " + " ,[EducationName] " + " ,[Description] " + " ,[Active] " + " ) " + "VALUES " + " ( " + " @EducationCode " + " ,@EducationName " + " ,@Description " + " ,@Active " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@EducationCode", clsDIC_EDUCATION.EducationCode); if (clsDIC_EDUCATION.EducationName != null) { insertCommand.Parameters.AddWithValue("@EducationName", clsDIC_EDUCATION.EducationName); } else { insertCommand.Parameters.AddWithValue("@EducationName", DBNull.Value); } if (clsDIC_EDUCATION.Description != null) { insertCommand.Parameters.AddWithValue("@Description", clsDIC_EDUCATION.Description); } else { insertCommand.Parameters.AddWithValue("@Description", DBNull.Value); } if (clsDIC_EDUCATION.Active.HasValue == true) { insertCommand.Parameters.AddWithValue("@Active", clsDIC_EDUCATION.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(); } }
public static bool Delete(DIC_EDUCATION clsDIC_EDUCATION) { SqlConnection connection = DAO_BASE.Get_Connection(); string deleteStatement = "DELETE FROM " + " [DIC_EDUCATION] " + "WHERE " + " [EducationCode] = @OldEducationCode " + " AND ((@OldEducationName IS NULL AND [EducationName] IS NULL) OR [EducationName] = @OldEducationName) " + " 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("@OldEducationCode", clsDIC_EDUCATION.EducationCode); if (clsDIC_EDUCATION.EducationName != null) { deleteCommand.Parameters.AddWithValue("@OldEducationName", clsDIC_EDUCATION.EducationName); } else { deleteCommand.Parameters.AddWithValue("@OldEducationName", DBNull.Value); } if (clsDIC_EDUCATION.Description != null) { deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_EDUCATION.Description); } else { deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (clsDIC_EDUCATION.Active.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_EDUCATION.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(); } }
public static bool Update(DIC_EDUCATION oldDIC_EDUCATION, DIC_EDUCATION newDIC_EDUCATION) { SqlConnection connection = DAO_BASE.Get_Connection(); string updateStatement = "UPDATE " + " [DIC_EDUCATION] " + "SET " + " [EducationCode] = @NewEducationCode " + " ,[EducationName] = @NewEducationName " + " ,[Description] = @NewDescription " + " ,[Active] = @NewActive " + "WHERE " + " [EducationCode] = @OldEducationCode " + " AND ((@OldEducationName IS NULL AND [EducationName] IS NULL) OR [EducationName] = @OldEducationName) " + " 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("@NewEducationCode", newDIC_EDUCATION.EducationCode); if (newDIC_EDUCATION.EducationName != null) { updateCommand.Parameters.AddWithValue("@NewEducationName", newDIC_EDUCATION.EducationName); } else { updateCommand.Parameters.AddWithValue("@NewEducationName", DBNull.Value); } if (newDIC_EDUCATION.Description != null) { updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_EDUCATION.Description); } else { updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value); } if (newDIC_EDUCATION.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@NewActive", newDIC_EDUCATION.Active); } else { updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldEducationCode", oldDIC_EDUCATION.EducationCode); if (oldDIC_EDUCATION.EducationName != null) { updateCommand.Parameters.AddWithValue("@OldEducationName", oldDIC_EDUCATION.EducationName); } else { updateCommand.Parameters.AddWithValue("@OldEducationName", DBNull.Value); } if (oldDIC_EDUCATION.Description != null) { updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_EDUCATION.Description); } else { updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (oldDIC_EDUCATION.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_EDUCATION.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(); } }
public override void Delete() { object cellValue; if (!(MyRule.Get(MyLogin.RoleId, "bbiEducation") != "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_EDUCATION dICEDUCATION = new DIC_EDUCATION(); for (int i = (int)selectedRows.Length; i > 0; i--) { flag = true; cellValue = base.GetCellValue(selectedRows[i - 1], "EducationCode"); if (cellValue != null) { // SYS_LOG.Insert("Danh Mục Học Vấn", "Xoá", cellValue.ToString()); str = dICEDUCATION.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, "EducationCode"); if (cellValue != null) { // SYS_LOG.Insert("Danh Mục Học Vấn", "Xoá", cellValue.ToString()); base.SetWaitDialogCaption("Đang xóa..."); str = dICEDUCATION.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 { MyRule.Notify(); } } }
private void frm_Added(object sender, DIC_EDUCATION e) { this.AddRow(e); }
private void frm_Updated(object sender, DIC_EDUCATION Item) { this.UpdateRow(Item, this.m_RowClickEventArgs); }