protected override void Add() { base.Add(); DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); this.txtID.Text = dICPROFESSIONAL.NewID(); this.txtNAME.Focus(); }
private bool Insert() { new_entity = new DIC_PROFESSIONAL(); new_entity.ProfessionalCode = txt_PROFESSIONAL_CODE.Text; new_entity.ProfessionalName = txt_PROFESSIONAL_NAME.Text; new_entity.Description = txt_DESCRIPTION.Text; new_entity.Active = true; ENT_RETURN validate = LOGIC_CHECK.Check_Data(new_entity); if (validate.Status) { DAO_DIC_PROFESSIONAL.Add(new_entity); if (parent != null) { parent.dg_DATA.DataSource = DAO_DIC_PROFESSIONAL.Get_Data(); } } else { XtraMessageBox.Show(validate.Message, "Loi"); return(false); } return(true); }
private void RaiseSuccessEventHander(DIC_PROFESSIONAL item) { if (this.Success != null) { this.Success(this, item); } }
protected override string uc_Save() { string str; if (MyRule.Get(MyLogin.RoleId, "bbiProfessional") != "OK") { str = ""; } else if (MyRule.AllowAdd) { // SYS_LOG.Insert("Danh Mục Chuyên Môn", "Thêm", this.txtID.Text); base.SetWaitDialogCaption("Đang lưu dữ liệu..."); Cursor.Current = Cursors.WaitCursor; DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked); string str1 = dICPROFESSIONAL.Insert(); if (str1 == "OK") { this.RaiseSuccessEventHander(dICPROFESSIONAL); } Cursor.Current = Cursors.Default; this.DoHide(); if (str1 != "OK") { XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } str = str1; } else { MyRule.Notify(); str = ""; } return str; }
public void RaiseUpdatedEventHander(DIC_PROFESSIONAL Item) { if (this.Updated != null) { this.Updated(this, Item); } }
public override void Change() { if (!(MyRule.Get(MyLogin.RoleId, "bbiProfessional") != "OK")) { if (MyRule.AllowAccess) { DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); object cellValue = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "ProfessionalCode"); if (cellValue != null) { base.SetWaitDialogCaption("Đang kiểm tra dữ liệu...."); if (!(dICPROFESSIONAL.Get(cellValue.ToString()) != "OK")) { this.DoHide(); xfmProfessionalAdd _xfmProfessionalAdd = new xfmProfessionalAdd(Actions.Update, dICPROFESSIONAL); _xfmProfessionalAdd.Updated += new xfmProfessionalAdd.UpdatedEventHander(this.frm_Updated); _xfmProfessionalAdd.Added += new xfmProfessionalAdd.AddedEventHander(this.frm_Added); _xfmProfessionalAdd.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(); } } }
public static ENT_RETURN Check_Data(DIC_PROFESSIONAL e) { ENT_RETURN ret = new ENT_RETURN(); string err_msg = string.Empty; // BEGIN CHECK if (Is_Empty_String(e.ProfessionalName)) { err_msg += GLOBAL.err_code["E004"]; } if (Is_Over_MaxLength(e.ProfessionalName, 100)) { err_msg += GLOBAL.err_code["E005"]; } 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 void frm_EDIT_Load(object sender, EventArgs e) { old_entity = new DIC_PROFESSIONAL(); old_entity.ProfessionalCode = CODE; old_entity = DAO_DIC_PROFESSIONAL.Select_Record(old_entity); txt_PROFESSIONAL_CODE.Text = old_entity.ProfessionalCode; txt_PROFESSIONAL_NAME.Text = old_entity.ProfessionalName; txt_DESCRIPTION.Text = old_entity.Description; }
public xfmProfessionalAdd(Actions Action) { this.InitializeComponent(); this.Init(); this.ucAdd.Status = Action; DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); this.ucAdd.SetData(dICPROFESSIONAL.NewID()); this.Text = "Thêm"; }
private void UpdateRow(DIC_PROFESSIONAL item, RowClickEventArgs e) { AdvBandedGridView advBandedGridView = this.gbList; int rowIndex = e.RowIndex; advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active); advBandedGridView.SetRowCellValue(rowIndex, "ProfessionalCode", item.ProfessionalCode); advBandedGridView.SetRowCellValue(rowIndex, "ProfessionalName", item.ProfessionalName); advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description); advBandedGridView.UpdateCurrentRow(); }
public void SetData(DIC_PROFESSIONAL item) { this.txtID.Text = item.ProfessionalCode; // SYS_LOG.Insert("Danh Mục Chuyên Môn", "Xem", this.txtID.Text); if (this.m_Status == Actions.Update) { this.txtID.Properties.ReadOnly = true; } this.txtNAME.Text = item.ProfessionalName; this.txtDescription.Text = item.Description; this.chxUse.Checked = item.Active; }
protected override string uc_Delete() { DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL() { ProfessionalCode = this.txtID.Text }; string str = dICPROFESSIONAL.Delete(); if (str == "OK") { this.RaiseSuccessEventHander(dICPROFESSIONAL); } return str; }
private void AddRow(DIC_PROFESSIONAL Item) { AdvBandedGridView advBandedGridView = this.gbList; int focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.AddNewRow(); focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active); advBandedGridView.SetRowCellValue(focusedRowHandle, "ProfessionalCode", Item.ProfessionalCode); advBandedGridView.SetRowCellValue(focusedRowHandle, "ProfessionalName", Item.ProfessionalName); advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description); advBandedGridView.UpdateCurrentRow(); }
public xfmProfessionalAdd(Actions Action, DIC_PROFESSIONAL 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.ProfessionalCode); } }
private void txtID_KeyDown(object sender, KeyEventArgs e) { TextEdit textEdit = (TextEdit)sender; if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab) { DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); if (this.m_Status == Actions.Add) { if (dICPROFESSIONAL.Exist(textEdit.Text)) { this.Err.SetError(textEdit, "Mã đã tồn tại."); textEdit.Focus(); } } } }
private void ucAdd_Success(object sender, DIC_PROFESSIONAL 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_PROFESSIONAL Select_Record(DIC_PROFESSIONAL clsDIC_PROFESSIONALPara) { DIC_PROFESSIONAL clsDIC_PROFESSIONAL = new DIC_PROFESSIONAL(); SqlConnection connection = DAO_BASE.Get_Connection(); string selectStatement = "SELECT " + " [ProfessionalCode] " + " ,[ProfessionalName] " + " ,[Description] " + " ,[Active] " + "FROM " + " [DIC_PROFESSIONAL] " + "WHERE " + " [ProfessionalCode] = @ProfessionalCode " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@ProfessionalCode", clsDIC_PROFESSIONALPara.ProfessionalCode); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsDIC_PROFESSIONAL.ProfessionalCode = System.Convert.ToString(reader["ProfessionalCode"]); clsDIC_PROFESSIONAL.ProfessionalName = reader["ProfessionalName"] is DBNull ? null : reader["ProfessionalName"].ToString(); clsDIC_PROFESSIONAL.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString(); clsDIC_PROFESSIONAL.Active = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"]; } else { clsDIC_PROFESSIONAL = null; } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return(clsDIC_PROFESSIONAL); }
private void btn_SAVE_Click(object sender, EventArgs e) { new_entity = new DIC_PROFESSIONAL(); new_entity.ProfessionalCode = txt_PROFESSIONAL_CODE.Text; new_entity.ProfessionalName = txt_PROFESSIONAL_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_PROFESSIONAL.Update(old_entity, new_entity); this.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show(validate.Message, "Loi"); } }
public override void ReLoad() { base.SetWaitDialogCaption("Đang nạp dữ liệu..."); DIC_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); this.gcList.DataSource = dICPROFESSIONAL.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, "bbiProfessional"); if (!MyRule.AllowPrint) { this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiProfessional"); if (!MyRule.AllowExport) { this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiProfessional"); if (!MyRule.AllowAdd) { this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiProfessional"); if (!MyRule.AllowDelete) { this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiProfessional"); if (!MyRule.AllowEdit) { this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never; } base.SetWaitDialogCaption("Đã xong..."); this.DoHide(); }
private void frm_Added(object sender, DIC_PROFESSIONAL e) { this.AddRow(e); }
public static bool Update(DIC_PROFESSIONAL oldDIC_PROFESSIONAL, DIC_PROFESSIONAL newDIC_PROFESSIONAL) { SqlConnection connection = DAO_BASE.Get_Connection(); string updateStatement = "UPDATE " + " [DIC_PROFESSIONAL] " + "SET " + " [ProfessionalCode] = @NewProfessionalCode " + " ,[ProfessionalName] = @NewProfessionalName " + " ,[Description] = @NewDescription " + " ,[Active] = @NewActive " + "WHERE " + " [ProfessionalCode] = @OldProfessionalCode " + " AND ((@OldProfessionalName IS NULL AND [ProfessionalName] IS NULL) OR [ProfessionalName] = @OldProfessionalName) " + " 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("@NewProfessionalCode", newDIC_PROFESSIONAL.ProfessionalCode); if (newDIC_PROFESSIONAL.ProfessionalName != null) { updateCommand.Parameters.AddWithValue("@NewProfessionalName", newDIC_PROFESSIONAL.ProfessionalName); } else { updateCommand.Parameters.AddWithValue("@NewProfessionalName", DBNull.Value); } if (newDIC_PROFESSIONAL.Description != null) { updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_PROFESSIONAL.Description); } else { updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value); } if (newDIC_PROFESSIONAL.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@NewActive", newDIC_PROFESSIONAL.Active); } else { updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldProfessionalCode", oldDIC_PROFESSIONAL.ProfessionalCode); if (oldDIC_PROFESSIONAL.ProfessionalName != null) { updateCommand.Parameters.AddWithValue("@OldProfessionalName", oldDIC_PROFESSIONAL.ProfessionalName); } else { updateCommand.Parameters.AddWithValue("@OldProfessionalName", DBNull.Value); } if (oldDIC_PROFESSIONAL.Description != null) { updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_PROFESSIONAL.Description); } else { updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (oldDIC_PROFESSIONAL.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_PROFESSIONAL.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 static bool Delete(DIC_PROFESSIONAL clsDIC_PROFESSIONAL) { SqlConnection connection = DAO_BASE.Get_Connection(); string deleteStatement = "DELETE FROM " + " [DIC_PROFESSIONAL] " + "WHERE " + " [ProfessionalCode] = @OldProfessionalCode " + " AND ((@OldProfessionalName IS NULL AND [ProfessionalName] IS NULL) OR [ProfessionalName] = @OldProfessionalName) " + " 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("@OldProfessionalCode", clsDIC_PROFESSIONAL.ProfessionalCode); if (clsDIC_PROFESSIONAL.ProfessionalName != null) { deleteCommand.Parameters.AddWithValue("@OldProfessionalName", clsDIC_PROFESSIONAL.ProfessionalName); } else { deleteCommand.Parameters.AddWithValue("@OldProfessionalName", DBNull.Value); } if (clsDIC_PROFESSIONAL.Description != null) { deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_PROFESSIONAL.Description); } else { deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (clsDIC_PROFESSIONAL.Active.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_PROFESSIONAL.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 override void Delete() { object cellValue; if (!(MyRule.Get(MyLogin.RoleId, "bbiProfessional") != "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_PROFESSIONAL dICPROFESSIONAL = new DIC_PROFESSIONAL(); for (int i = (int)selectedRows.Length; i > 0; i--) { flag = true; cellValue = base.GetCellValue(selectedRows[i - 1], "ProfessionalCode"); if (cellValue != null) { // SYS_LOG.Insert("Danh Mục Chuyên Môn", "Xoá", cellValue.ToString()); str = dICPROFESSIONAL.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, "ProfessionalCode"); if (cellValue != null) { // SYS_LOG.Insert("Danh Mục Chuyên Môn", "Xoá", cellValue.ToString()); base.SetWaitDialogCaption("Đang xóa..."); str = dICPROFESSIONAL.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(); } } }
public static bool Add(DIC_PROFESSIONAL clsDIC_PROFESSIONAL) { SqlConnection connection = DAO_BASE.Get_Connection(); string insertStatement = "INSERT " + " [DIC_PROFESSIONAL] " + " ( " + " [ProfessionalCode] " + " ,[ProfessionalName] " + " ,[Description] " + " ,[Active] " + " ) " + "VALUES " + " ( " + " @ProfessionalCode " + " ,@ProfessionalName " + " ,@Description " + " ,@Active " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@ProfessionalCode", clsDIC_PROFESSIONAL.ProfessionalCode); if (clsDIC_PROFESSIONAL.ProfessionalName != null) { insertCommand.Parameters.AddWithValue("@ProfessionalName", clsDIC_PROFESSIONAL.ProfessionalName); } else { insertCommand.Parameters.AddWithValue("@ProfessionalName", DBNull.Value); } if (clsDIC_PROFESSIONAL.Description != null) { insertCommand.Parameters.AddWithValue("@Description", clsDIC_PROFESSIONAL.Description); } else { insertCommand.Parameters.AddWithValue("@Description", DBNull.Value); } if (clsDIC_PROFESSIONAL.Active.HasValue == true) { insertCommand.Parameters.AddWithValue("@Active", clsDIC_PROFESSIONAL.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(); } }
private void frm_Updated(object sender, DIC_PROFESSIONAL Item) { this.UpdateRow(Item, this.m_RowClickEventArgs); }