private void RaiseSuccessEventHander(DIC_SALARY_STEP item) { if (this.Success != null) { this.Success(this, item); } }
public override void Change() { if (MyRule.IsAccess("bbiStep")) { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); object focusedRowCellValue = this.gbList.GetFocusedRowCellValue("StepCode"); object obj = this.gbList.GetFocusedRowCellValue("RankCode"); if (focusedRowCellValue != null) { base.SetWaitDialogCaption("Đang kiểm tra dữ liệu...."); if (!(dICSALARYSTEP.Get(focusedRowCellValue.ToString(), obj.ToString()) != "OK")) { this.DoHide(); xfmStepAdd _xfmStepAdd = new xfmStepAdd(Actions.Update, dICSALARYSTEP); _xfmStepAdd.Updated += new xfmStepAdd.UpdatedEventHander(this.frm_Updated); _xfmStepAdd.Added += new xfmStepAdd.AddedEventHander(this.frm_Added); _xfmStepAdd.ShowDialog(); } else { this.DoHide(); XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }
protected override string uc_Update() { string str; if (MyRule.Get(MyLogin.RoleId, "bbiStep") != "OK") { str = ""; } else if (MyRule.AllowEdit) { // SYS_LOG.Insert("Danh Mục Bậc Lương", "Cập Nhật", this.txtID.Text); base.SetWaitDialogCaption("Đang cập nhật dữ liệu..."); DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(int.Parse(this.txtID.Text), this.glkRank.EditValue.ToString(), this.txtNAME.Text, double.Parse(this.calCoefficient.Text), this.txtDescription.Text); string str1 = dICSALARYSTEP.Update(); if (str1 == "OK") { this.RaiseSuccessEventHander(dICSALARYSTEP); } if (str1 != "OK") { XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.DoHide(); str = str1; } else { MyRule.Notify(); str = ""; } return(str); }
private void RaiseItemSelectedEventHander(DIC_SALARY_STEP item) { if (this.ItemSelected != null) { this.ItemSelected(this, item); } }
public void RaiseUpdatedEventHander(DIC_SALARY_STEP Item) { if (this.Updated != null) { this.Updated(this, Item); } }
public override void Delete() { string str; object rowCellValue; if (MyRule.IsDelete("bbiStep")) { bool flag = false; int[] selectedRows = this.gbList.GetSelectedRows(); if (XtraMessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No) { base.SetWaitDialogCaption("Đang xóa..."); DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); for (int i = (int)selectedRows.Length; i > 0; i--) { flag = true; rowCellValue = this.gbList.GetRowCellValue(selectedRows[i - 1], "StepCode"); if (rowCellValue != null) { // SYS_LOG.Insert("Danh Mục Bậc Lương", "Xoá", rowCellValue.ToString()); str = dICSALARYSTEP.Delete(rowCellValue.ToString()); if (str == "OK") { this.gbList.DeleteRow(this.gbList.FocusedRowHandle); } else if (str != "OK") { MessageBox.Show(string.Concat("Thông tin không được xóa\r\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } this.DoHide(); if (!flag) { if (dICSALARYSTEP.GetList().Rows.Count != 0) { rowCellValue = this.gbList.GetFocusedRowCellValue("StepCode"); if (rowCellValue != null) { // SYS_LOG.Insert("Danh Mục Bậc Lương", "Xoá", rowCellValue.ToString()); base.SetWaitDialogCaption("Đang xóa..."); str = dICSALARYSTEP.Delete(rowCellValue.ToString()); if (str == "OK") { this.gbList.DeleteRow(this.gbList.FocusedRowHandle); } else if (str != "OK") { MessageBox.Show(string.Concat("Thông tin không được xóa\r\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand); } this.DoHide(); } } } } } }
public xfmStepAdd(Actions Action) { this.InitializeComponent(); this.Init(); this.ucAdd.Status = Action; DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); this.ucAdd.SetID(dICSALARYSTEP.NewID()); this.Text = "Thêm"; }
public override void ReLoad() { base.SetWaitDialogCaption("Đang nạp dữ liệu..."); DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); this.gcList.DataSource = dICSALARYSTEP.GetList(); base.SetWaitDialogCaption("Đang nạp cấu hình..."); this.gbList.ClearColumnsFilter(); base.SetWaitDialogCaption("Đã xong..."); this.DoHide(); }
private void UpdateRow(DIC_SALARY_STEP item) { GridView gridView = this.gbList; int focusedRowHandle = this.gbList.FocusedRowHandle; gridView.SetRowCellValue(focusedRowHandle, "StepCode", item.StepCode); gridView.SetRowCellValue(focusedRowHandle, "RankCode", item.RankCode); gridView.SetRowCellValue(focusedRowHandle, "StepName", item.StepName); gridView.SetRowCellValue(focusedRowHandle, "Coefficient", item.Coefficient); gridView.SetRowCellValue(focusedRowHandle, "Description", item.Description); gridView.UpdateCurrentRow(); }
protected override void Add() { base.Add(); try { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); this.SetID(dICSALARYSTEP.NewID(this.glkRank.EditValue.ToString())); } catch { } }
public static DIC_SALARY_STEP Select_Record(DIC_SALARY_STEP clsDIC_SALARY_STEPPara) { DIC_SALARY_STEP clsDIC_SALARY_STEP = new DIC_SALARY_STEP(); SqlConnection connection = DAO_BASE.Get_Connection(); string selectStatement = "SELECT " + " [StepCode] " + " ,[RankCode] " + " ,[StepName] " + " ,[Coefficient] " + " ,[Description] " + "FROM " + " [DIC_SALARY_STEP] " + "WHERE " + " [StepCode] = @StepCode " + " AND [RankCode] = @RankCode " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@StepCode", clsDIC_SALARY_STEPPara.StepCode); selectCommand.Parameters.AddWithValue("@RankCode", clsDIC_SALARY_STEPPara.RankCode); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsDIC_SALARY_STEP.StepCode = System.Convert.ToInt32(reader["StepCode"]); clsDIC_SALARY_STEP.RankCode = System.Convert.ToString(reader["RankCode"]); clsDIC_SALARY_STEP.StepName = reader["StepName"] is DBNull ? null : reader["StepName"].ToString(); clsDIC_SALARY_STEP.Coefficient = reader["Coefficient"] is DBNull ? null : (Decimal?)(Double?)reader["Coefficient"]; clsDIC_SALARY_STEP.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString(); } else { clsDIC_SALARY_STEP = null; } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return(clsDIC_SALARY_STEP); }
public void SetData(DIC_SALARY_STEP item) { this.txtID.Text = item.StepCode.ToString(); this.glkRank.EditValue = item.RankCode; // SYS_LOG.Insert("Danh Mục Bậc Lương", "Xem", this.txtID.Text); if (this.m_Status == Actions.Update) { this.txtID.Properties.ReadOnly = true; this.glkRank.Properties.ReadOnly = true; } this.txtNAME.Text = item.StepName; this.calCoefficient.Text = item.Coefficient.ToString(); this.txtDescription.Text = item.Description; }
protected override string uc_Delete() { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP() { StepCode = int.Parse(this.txtID.Text) }; DIC_SALARY_STEP dICSALARYSTEP1 = dICSALARYSTEP; string str = dICSALARYSTEP1.Delete(); if (str == "OK") { this.RaiseSuccessEventHander(dICSALARYSTEP1); } return(str); }
public xfmStepAdd(Actions Action, DIC_SALARY_STEP 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.RankCode); } }
private void ucAdd_Success(object sender, DIC_SALARY_STEP 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(); }
private void glkRank_EditValueChanged(object sender, EventArgs e) { if (this.txtID.ErrorText != string.Empty) { this.Err.SetError(this.txtID, string.Empty); } if (this.m_Status == Actions.Add) { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); this.SetID(dICSALARYSTEP.NewID(this.glkRank.EditValue.ToString())); if (dICSALARYSTEP.Exist(this.txtID.Text, this.glkRank.EditValue.ToString())) { this.Err.SetError(this.txtID, "Mã đã tồn tại."); this.txtID.Focus(); } } }
protected override void txtID_KeyDown(object sender, KeyEventArgs e) { TextEdit textEdit = (TextEdit)sender; if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab) { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); if (this.m_Status == Actions.Add) { if (dICSALARYSTEP.Exist(textEdit.Text, this.glkRank.EditValue.ToString())) { this.Err.SetError(textEdit, "Mã đã tồn tại."); textEdit.Focus(); } } } }
private void Init() { MyRule.Check("bbiStep"); this.ucToolBar.bbiPrint.Visibility = MyRule.Printed; this.ucToolBar.bbiExport.Visibility = MyRule.Exported; this.ucToolBar.bbiAdd.Visibility = MyRule.Added; this.ucToolBar.bbiDelete.Visibility = MyRule.Deleted; this.ucToolBar.bbiEdit.Visibility = MyRule.Edited; base.RibbonBar.Add.Visibility = MyRule.Added; base.RibbonBar.Change.Visibility = MyRule.Edited; base.RibbonBar.Delete.Visibility = MyRule.Deleted; base.RibbonBar.Print.Visibility = MyRule.Printed; base.RibbonBar.Export.Visibility = MyRule.Exported; base.RibbonBar.Import.Visibility = MyRule.Imported; DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); this.gcList.DataSource = dICSALARYSTEP.GetList(); }
private void txtID_EditValueChanged_1(object sender, EventArgs e) { TextEdit textEdit = (TextEdit)sender; if (textEdit.ErrorText != string.Empty) { this.Err.SetError(textEdit, string.Empty); } if (this.m_Status == Actions.Add) { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); if (this.glkRank.EditValue != null) { if (dICSALARYSTEP.Exist(textEdit.Text, this.glkRank.EditValue.ToString())) { this.Err.SetError(textEdit, "Mã đã tồn tại."); textEdit.Focus(); } } } }
protected override string uc_Save() { string str; if (MyRule.Get(MyLogin.RoleId, "bbiStep") != "OK") { str = ""; } else if (!MyRule.AllowAdd) { MyRule.Notify(); str = ""; } else if (this.glkRank.EditValue != null) { // SYS_LOG.Insert("Danh Mục Bậc Lương", "Thêm", this.txtID.Text); base.SetWaitDialogCaption("Đang lưu dữ liệu..."); Cursor.Current = Cursors.WaitCursor; DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(int.Parse(this.txtID.Text), this.glkRank.EditValue.ToString(), this.txtNAME.Text, double.Parse(this.calCoefficient.Text), this.txtDescription.Text); string str1 = dICSALARYSTEP.Insert(); if (str1 == "OK") { this.RaiseSuccessEventHander(dICSALARYSTEP); } Cursor.Current = Cursors.Default; this.DoHide(); if (str1 != "OK") { XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } str = str1; } else { XtraMessageBox.Show("Vui lòng chọn ngạch lương tương ứng!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); str = ""; } return(str); }
public override void SetSearch(CHBK2014_N9.Common.Class.RowClickEventArgs e) { if (this._search) { DIC_SALARY_STEP dICSALARYSTEP = new DIC_SALARY_STEP(); object rowCellValue = this.gbList.GetRowCellValue(this.MRowClickEventArgs.RowIndex, "StepCode"); object obj = this.gbList.GetRowCellValue(this.MRowClickEventArgs.RowIndex, "RankCode"); if (rowCellValue != null) { base.SetWaitDialogCaption("Đang kiểm tra dữ liệu...."); if (!(dICSALARYSTEP.Get(rowCellValue.ToString(), obj.ToString()) != "OK")) { this.DoHide(); this.RaiseItemSelectedEventHander(dICSALARYSTEP); } else { this.DoHide(); XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }
public static bool Update(DIC_SALARY_STEP oldDIC_SALARY_STEP, DIC_SALARY_STEP newDIC_SALARY_STEP) { SqlConnection connection = DAO_BASE.Get_Connection(); string updateStatement = "UPDATE " + " [DIC_SALARY_STEP] " + "SET " + " [StepCode] = @NewStepCode " + " ,[RankCode] = @NewRankCode " + " ,[StepName] = @NewStepName " + " ,[Coefficient] = @NewCoefficient " + " ,[Description] = @NewDescription " + "WHERE " + " [StepCode] = @OldStepCode " + " AND [RankCode] = @OldRankCode " + " AND ((@OldStepName IS NULL AND [StepName] IS NULL) OR [StepName] = @OldStepName) " + " AND ((@OldCoefficient IS NULL AND [Coefficient] IS NULL) OR [Coefficient] = @OldCoefficient) " + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) " + ""; SqlCommand updateCommand = new SqlCommand(updateStatement, connection); updateCommand.CommandType = CommandType.Text; updateCommand.Parameters.AddWithValue("@NewStepCode", newDIC_SALARY_STEP.StepCode); updateCommand.Parameters.AddWithValue("@NewRankCode", newDIC_SALARY_STEP.RankCode); if (newDIC_SALARY_STEP.StepName != null) { updateCommand.Parameters.AddWithValue("@NewStepName", newDIC_SALARY_STEP.StepName); } else { updateCommand.Parameters.AddWithValue("@NewStepName", DBNull.Value); } if (newDIC_SALARY_STEP.Coefficient.HasValue == true) { updateCommand.Parameters.AddWithValue("@NewCoefficient", newDIC_SALARY_STEP.Coefficient); } else { updateCommand.Parameters.AddWithValue("@NewCoefficient", DBNull.Value); } if (newDIC_SALARY_STEP.Description != null) { updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_SALARY_STEP.Description); } else { updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldStepCode", oldDIC_SALARY_STEP.StepCode); updateCommand.Parameters.AddWithValue("@OldRankCode", oldDIC_SALARY_STEP.RankCode); if (oldDIC_SALARY_STEP.StepName != null) { updateCommand.Parameters.AddWithValue("@OldStepName", oldDIC_SALARY_STEP.StepName); } else { updateCommand.Parameters.AddWithValue("@OldStepName", DBNull.Value); } if (oldDIC_SALARY_STEP.Coefficient.HasValue == true) { updateCommand.Parameters.AddWithValue("@OldCoefficient", oldDIC_SALARY_STEP.Coefficient); } else { updateCommand.Parameters.AddWithValue("@OldCoefficient", DBNull.Value); } if (oldDIC_SALARY_STEP.Description != null) { updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_SALARY_STEP.Description); } else { updateCommand.Parameters.AddWithValue("@OldDescription", 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_SALARY_STEP clsDIC_SALARY_STEP) { SqlConnection connection = DAO_BASE.Get_Connection(); string deleteStatement = "DELETE FROM " + " [DIC_SALARY_STEP] " + "WHERE " + " [StepCode] = @OldStepCode " + " AND [RankCode] = @OldRankCode " + " AND ((@OldStepName IS NULL AND [StepName] IS NULL) OR [StepName] = @OldStepName) " + " AND ((@OldCoefficient IS NULL AND [Coefficient] IS NULL) OR [Coefficient] = @OldCoefficient) " + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) " + ""; SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection); deleteCommand.CommandType = CommandType.Text; deleteCommand.Parameters.AddWithValue("@OldStepCode", clsDIC_SALARY_STEP.StepCode); deleteCommand.Parameters.AddWithValue("@OldRankCode", clsDIC_SALARY_STEP.RankCode); if (clsDIC_SALARY_STEP.StepName != null) { deleteCommand.Parameters.AddWithValue("@OldStepName", clsDIC_SALARY_STEP.StepName); } else { deleteCommand.Parameters.AddWithValue("@OldStepName", DBNull.Value); } if (clsDIC_SALARY_STEP.Coefficient.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldCoefficient", clsDIC_SALARY_STEP.Coefficient); } else { deleteCommand.Parameters.AddWithValue("@OldCoefficient", DBNull.Value); } if (clsDIC_SALARY_STEP.Description != null) { deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_SALARY_STEP.Description); } else { deleteCommand.Parameters.AddWithValue("@OldDescription", 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 Add(DIC_SALARY_STEP clsDIC_SALARY_STEP) { SqlConnection connection = DAO_BASE.Get_Connection(); string insertStatement = "INSERT " + " [DIC_SALARY_STEP] " + " ( " + " [StepCode] " + " ,[RankCode] " + " ,[StepName] " + " ,[Coefficient] " + " ,[Description] " + " ) " + "VALUES " + " ( " + " @StepCode " + " ,@RankCode " + " ,@StepName " + " ,@Coefficient " + " ,@Description " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@StepCode", clsDIC_SALARY_STEP.StepCode); insertCommand.Parameters.AddWithValue("@RankCode", clsDIC_SALARY_STEP.RankCode); if (clsDIC_SALARY_STEP.StepName != null) { insertCommand.Parameters.AddWithValue("@StepName", clsDIC_SALARY_STEP.StepName); } else { insertCommand.Parameters.AddWithValue("@StepName", DBNull.Value); } if (clsDIC_SALARY_STEP.Coefficient.HasValue == true) { insertCommand.Parameters.AddWithValue("@Coefficient", clsDIC_SALARY_STEP.Coefficient); } else { insertCommand.Parameters.AddWithValue("@Coefficient", DBNull.Value); } if (clsDIC_SALARY_STEP.Description != null) { insertCommand.Parameters.AddWithValue("@Description", clsDIC_SALARY_STEP.Description); } else { insertCommand.Parameters.AddWithValue("@Description", 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_Added(object sender, DIC_SALARY_STEP Item) { this.ReLoad(); }
private void frm_Updated(object sender, DIC_SALARY_STEP Item) { this.UpdateRow(Item); }