protected override string uc_Save() { string str; if (MyRule.Get(MyLogin.RoleId, "bbiDegree") != "OK") { str = ""; } else if (MyRule.AllowAdd) { // SYS_LOG.Insert("Danh Mục Bằng Cấp", "Thêm", this.txtID.Text); base.SetWaitDialogCaption("Đang lưu dữ liệu..."); Cursor.Current = Cursors.WaitCursor; DIC_DEGREE dICDEGREE = new DIC_DEGREE(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked); string str1 = dICDEGREE.Insert(); if (str1 == "OK") { this.RaiseSuccessEventHander(dICDEGREE); } 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); }
private void RaiseSuccessEventHander(DIC_DEGREE item) { if (this.Success != null) { this.Success(this, item); } }
public void RaiseUpdatedEventHander(DIC_DEGREE Item) { if (this.Updated != null) { this.Updated(this, Item); } }
public override void Change() { if (!(MyRule.Get(MyLogin.RoleId, "bbiDegree") != "OK")) { if (MyRule.AllowAccess) { DIC_DEGREE dICDEGREE = new DIC_DEGREE(); object cellValue = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "DegreeCode"); if (cellValue != null) { base.SetWaitDialogCaption("Đang kiểm tra dữ liệu...."); if (!(dICDEGREE.Get(cellValue.ToString()) != "OK")) { this.DoHide(); xfmDegreeAdd _xfmDegreeAdd = new xfmDegreeAdd(Actions.Update, dICDEGREE); _xfmDegreeAdd.Updated += new xfmDegreeAdd.UpdatedEventHander(this.frm_Updated); _xfmDegreeAdd.Added += new xfmDegreeAdd.AddedEventHander(this.frm_Added); _xfmDegreeAdd.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(); } } }
private void RaiseItemSelectedEventHander(DIC_DEGREE item) { if (this.ItemSelected != null) { this.ItemSelected(this, item); } }
protected override void Add() { base.Add(); DIC_DEGREE dICDEGREE = new DIC_DEGREE(); this.txtID.Text = dICDEGREE.NewID(); this.txtNAME.Focus(); }
public xfmDegreeAdd(Actions Action) { this.InitializeComponent(); this.Init(); this.ucAdd.Status = Action; DIC_DEGREE dICDEGREE = new DIC_DEGREE(); this.ucAdd.SetData(dICDEGREE.NewID()); this.Text = "Thêm"; }
private void UpdateRow(DIC_DEGREE item, RowClickEventArgs e) { AdvBandedGridView advBandedGridView = this.gbList; int rowIndex = e.RowIndex; advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active); advBandedGridView.SetRowCellValue(rowIndex, "DegreeCode", item.DegreeCode); advBandedGridView.SetRowCellValue(rowIndex, "DegreeName", item.DegreeName); advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description); advBandedGridView.UpdateCurrentRow(); }
public void SetData(DIC_DEGREE item) { this.txtID.Text = item.DegreeCode; // SYS_LOG.Insert("Danh Mục Bằng Cấp", "Xem", this.txtID.Text); if (this.m_Status == Actions.Update) { this.txtID.Properties.ReadOnly = true; } this.txtNAME.Text = item.DegreeName; this.txtDescription.Text = item.Description; this.chxUse.Checked = item.Active; }
private void AddRow(DIC_DEGREE Item) { AdvBandedGridView advBandedGridView = this.gbList; int focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.AddNewRow(); focusedRowHandle = advBandedGridView.FocusedRowHandle; advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active); advBandedGridView.SetRowCellValue(focusedRowHandle, "DegreeCode", Item.DegreeCode); advBandedGridView.SetRowCellValue(focusedRowHandle, "DegreeName", Item.DegreeName); advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description); advBandedGridView.UpdateCurrentRow(); }
protected override string uc_Delete() { DIC_DEGREE dICDEGREE = new DIC_DEGREE() { DegreeCode = this.txtID.Text }; string str = dICDEGREE.Delete(); if (str == "OK") { this.RaiseSuccessEventHander(dICDEGREE); } return(str); }
public xfmDegreeAdd(Actions Action, DIC_DEGREE 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.DegreeCode); } }
private void ucAdd_Success(object sender, DIC_DEGREE 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_DEGREE Select_Record(DIC_DEGREE clsDIC_DEGREEPara) { DIC_DEGREE clsDIC_DEGREE = new DIC_DEGREE(); SqlConnection connection = DAO_BASE.Get_Connection(); string selectStatement = "SELECT " + " [DegreeCode] " + " ,[DegreeName] " + " ,[Description] " + " ,[Active] " + "FROM " + " [DIC_DEGREE] " + "WHERE " + " [DegreeCode] = @DegreeCode " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@DegreeCode", clsDIC_DEGREEPara.DegreeCode); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsDIC_DEGREE.DegreeCode = System.Convert.ToString(reader["DegreeCode"]); clsDIC_DEGREE.DegreeName = reader["DegreeName"] is DBNull ? null : reader["DegreeName"].ToString(); clsDIC_DEGREE.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString(); clsDIC_DEGREE.Active = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"]; } else { clsDIC_DEGREE = null; } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return(clsDIC_DEGREE); }
protected override void txtID_KeyDown(object sender, KeyEventArgs e) { TextEdit textEdit = (TextEdit)sender; if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab) { DIC_DEGREE dICDEGREE = new DIC_DEGREE(); if (this.m_Status == Actions.Add) { if (dICDEGREE.Exist(textEdit.Text)) { this.Err.SetError(textEdit, "Mã đã tồn tại."); textEdit.Focus(); } } } }
public override void ReLoad() { base.SetWaitDialogCaption("Đang nạp dữ liệu..."); DIC_DEGREE dICDEGREE = new DIC_DEGREE(); this.gcList.DataSource = dICDEGREE.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, "bbiDegree"); if (!MyRule.AllowPrint) { this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiDegree"); if (!MyRule.AllowExport) { this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiDegree"); if (!MyRule.AllowAdd) { this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiDegree"); if (!MyRule.AllowDelete) { this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never; } MyRule.Get(MyLogin.RoleId, "bbiDegree"); if (!MyRule.AllowEdit) { this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never; } base.SetWaitDialogCaption("Đã xong..."); this.DoHide(); }
public override void Delete() { object cellValue; if (!(MyRule.Get(MyLogin.RoleId, "bbiDegree") != "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_DEGREE dICDEGREE = new DIC_DEGREE(); for (int i = (int)selectedRows.Length; i > 0; i--) { flag = true; cellValue = base.GetCellValue(selectedRows[i - 1], "DegreeCode"); if (cellValue != null) { SYS_LOG.Insert("Danh Mục Bằng Cấp", "Xoá", cellValue.ToString()); str = dICDEGREE.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, "DegreeCode"); if (cellValue != null) { SYS_LOG.Insert("Danh Mục Bằng Cấp", "Xoá", cellValue.ToString()); base.SetWaitDialogCaption("Đang xóa..."); str = dICDEGREE.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 Delete(DIC_DEGREE clsDIC_DEGREE) { SqlConnection connection = DAO_BASE.Get_Connection(); string deleteStatement = "DELETE FROM " + " [DIC_DEGREE] " + "WHERE " + " [DegreeCode] = @OldDegreeCode " + " AND ((@OldDegreeName IS NULL AND [DegreeName] IS NULL) OR [DegreeName] = @OldDegreeName) " + " 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("@OldDegreeCode", clsDIC_DEGREE.DegreeCode); if (clsDIC_DEGREE.DegreeName != null) { deleteCommand.Parameters.AddWithValue("@OldDegreeName", clsDIC_DEGREE.DegreeName); } else { deleteCommand.Parameters.AddWithValue("@OldDegreeName", DBNull.Value); } if (clsDIC_DEGREE.Description != null) { deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_DEGREE.Description); } else { deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (clsDIC_DEGREE.Active.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_DEGREE.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 Add(DIC_DEGREE clsDIC_DEGREE) { SqlConnection connection = DAO_BASE.Get_Connection(); string insertStatement = "INSERT " + " [DIC_DEGREE] " + " ( " + " [DegreeCode] " + " ,[DegreeName] " + " ,[Description] " + " ,[Active] " + " ) " + "VALUES " + " ( " + " @DegreeCode " + " ,@DegreeName " + " ,@Description " + " ,@Active " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@DegreeCode", clsDIC_DEGREE.DegreeCode); if (clsDIC_DEGREE.DegreeName != null) { insertCommand.Parameters.AddWithValue("@DegreeName", clsDIC_DEGREE.DegreeName); } else { insertCommand.Parameters.AddWithValue("@DegreeName", DBNull.Value); } if (clsDIC_DEGREE.Description != null) { insertCommand.Parameters.AddWithValue("@Description", clsDIC_DEGREE.Description); } else { insertCommand.Parameters.AddWithValue("@Description", DBNull.Value); } if (clsDIC_DEGREE.Active.HasValue == true) { insertCommand.Parameters.AddWithValue("@Active", clsDIC_DEGREE.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 Update(DIC_DEGREE oldDIC_DEGREE, DIC_DEGREE newDIC_DEGREE) { SqlConnection connection = DAO_BASE.Get_Connection(); string updateStatement = "UPDATE " + " [DIC_DEGREE] " + "SET " + " [DegreeCode] = @NewDegreeCode " + " ,[DegreeName] = @NewDegreeName " + " ,[Description] = @NewDescription " + " ,[Active] = @NewActive " + "WHERE " + " [DegreeCode] = @OldDegreeCode " + " AND ((@OldDegreeName IS NULL AND [DegreeName] IS NULL) OR [DegreeName] = @OldDegreeName) " + " 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("@NewDegreeCode", newDIC_DEGREE.DegreeCode); if (newDIC_DEGREE.DegreeName != null) { updateCommand.Parameters.AddWithValue("@NewDegreeName", newDIC_DEGREE.DegreeName); } else { updateCommand.Parameters.AddWithValue("@NewDegreeName", DBNull.Value); } if (newDIC_DEGREE.Description != null) { updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_DEGREE.Description); } else { updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value); } if (newDIC_DEGREE.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@NewActive", newDIC_DEGREE.Active); } else { updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldDegreeCode", oldDIC_DEGREE.DegreeCode); if (oldDIC_DEGREE.DegreeName != null) { updateCommand.Parameters.AddWithValue("@OldDegreeName", oldDIC_DEGREE.DegreeName); } else { updateCommand.Parameters.AddWithValue("@OldDegreeName", DBNull.Value); } if (oldDIC_DEGREE.Description != null) { updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_DEGREE.Description); } else { updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value); } if (oldDIC_DEGREE.Active.HasValue == true) { updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_DEGREE.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(); } }
private void frm_Updated(object sender, DIC_DEGREE Item) { this.UpdateRow(Item, this.m_RowClickEventArgs); }
private void frm_Added(object sender, DIC_DEGREE e) { this.AddRow(e); }