private Int64 UpdateTran(HREmployeeNoticeEntity hREmployeeNoticeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeNotice_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@EmployeeNoticeID", DbType.Int64, hREmployeeNoticeEntity.EmployeeNoticeID); db.AddInParameter(cmd, "@SendToEmployeeID", DbType.Int64, hREmployeeNoticeEntity.SendToEmployeeID); db.AddInParameter(cmd, "@Memo", DbType.String, hREmployeeNoticeEntity.Memo); db.AddInParameter(cmd, "@Text", DbType.String, hREmployeeNoticeEntity.Text); db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeNoticeEntity.Remarks); db.AddInParameter(cmd, "@NoticeDate", DbType.DateTime, hREmployeeNoticeEntity.NoticeDate); db.AddInParameter(cmd, "@PreparedByEmployeeID", DbType.Int64, hREmployeeNoticeEntity.PreparedByEmployeeID); db.AddInParameter(cmd, "@PreparedByEmployeeSalaryLevel", DbType.Int32, hREmployeeNoticeEntity.PreparedByEmployeeSalaryLevel); db.AddInParameter(cmd, "@TemplateID", DbType.Int64, hREmployeeNoticeEntity.TemplateID); db.AddInParameter(cmd, "@SeenNotice", DbType.DateTime, hREmployeeNoticeEntity.SeenNotice); db.AddInParameter(cmd, "@ViewCount", DbType.Int64, hREmployeeNoticeEntity.ViewCount); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
Int64 IHREmployeeNoticeDataAccess.Add(HREmployeeNoticeEntity hREmployeeNoticeEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeeNoticeEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeeNoticeEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { HREmployeeNoticeEntity hREmployeeNoticeEntity = CurrentHREmployeeNoticeEntity; if (!hREmployeeNoticeEntity.IsNew) { if (ddlSendToEmployeeID.Items.Count > 0 && hREmployeeNoticeEntity.SendToEmployeeID != null) { ddlSendToEmployeeID.SelectedValue = hREmployeeNoticeEntity.SendToEmployeeID.ToString(); } txtMemo.Text = hREmployeeNoticeEntity.Memo.ToString(); txtText.Content = hREmployeeNoticeEntity.Text.ToString(); txtRemarks.Text = hREmployeeNoticeEntity.Remarks.ToString(); txtNoticeDate.Text = hREmployeeNoticeEntity.NoticeDate.ToStringDefault(); if (ddlTemplateID.Items.Count > 0 && hREmployeeNoticeEntity.TemplateID != null) { ddlTemplateID.SelectedValue = hREmployeeNoticeEntity.TemplateID.ToString(); } btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private HREmployeeNoticeEntity BuildHREmployeeNoticeEntity() { HREmployeeNoticeEntity hREmployeeNoticeEntity = CurrentHREmployeeNoticeEntity; return(hREmployeeNoticeEntity); }
private HREmployeeNoticeEntity BuildHREmployeeNoticeEntity() { HREmployeeNoticeEntity hREmployeeNoticeEntity = new HREmployeeNoticeEntity(); return(hREmployeeNoticeEntity); }
private void PrepareEditView() { HREmployeeNoticeEntity hREmployeeNoticeEntity = CurrentHREmployeeNoticeEntity; if (!hREmployeeNoticeEntity.IsNew) { } }
private void SaveHREmployeeNoticeEntity() { if (IsValid) { try { HREmployeeNoticeEntity hREmployeeNoticeEntity = BuildHREmployeeNoticeEntity(); Int64 result = -1; if (hREmployeeNoticeEntity.IsNew) { result = FCCHREmployeeNotice.GetFacadeCreate().Add(hREmployeeNoticeEntity, DatabaseOperationType.Add, TransactionRequired.No); SendMail(hREmployeeNoticeEntity); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeNoticeEntity.FLD_NAME_EmployeeNoticeID, hREmployeeNoticeEntity.EmployeeNoticeID.ToString(), SQLMatchType.Equal); result = FCCHREmployeeNotice.GetFacadeCreate().Update(hREmployeeNoticeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeNoticeID = 0; _HREmployeeNoticeEntity = new HREmployeeNoticeEntity(); PrepareInitialView(); BindHREmployeeNoticeList(); if (hREmployeeNoticeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Notice Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Notice Information has been updated successfully.", false); } } else { if (hREmployeeNoticeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Notice Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Notice Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvHREmployeeNotice_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeeNoticeID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeeNoticeID); if (EmployeeNoticeID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeeNoticeID = EmployeeNoticeID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeNoticeEntity.FLD_NAME_EmployeeNoticeID, EmployeeNoticeID.ToString(), SQLMatchType.Equal); HREmployeeNoticeEntity hREmployeeNoticeEntity = new HREmployeeNoticeEntity(); result = FCCHREmployeeNotice.GetFacadeCreate().Delete(hREmployeeNoticeEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeeNoticeID = 0; _HREmployeeNoticeEntity = new HREmployeeNoticeEntity(); PrepareInitialView(); BindHREmployeeNoticeList(); MiscUtil.ShowMessage(lblMessage, "Employee Notice has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Notice.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(HREmployeeNoticeEntity hREmployeeNoticeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeNotice_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private Int64 Update(HREmployeeNoticeEntity hREmployeeNoticeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeNotice_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeeNoticeID", DbType.Int64, hREmployeeNoticeEntity.EmployeeNoticeID); Database.AddInParameter(cmd, "@SendToEmployeeID", DbType.Int64, hREmployeeNoticeEntity.SendToEmployeeID); Database.AddInParameter(cmd, "@Memo", DbType.String, hREmployeeNoticeEntity.Memo); Database.AddInParameter(cmd, "@Text", DbType.String, hREmployeeNoticeEntity.Text); Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeNoticeEntity.Remarks); Database.AddInParameter(cmd, "@NoticeDate", DbType.DateTime, hREmployeeNoticeEntity.NoticeDate); Database.AddInParameter(cmd, "@PreparedByEmployeeID", DbType.Int64, hREmployeeNoticeEntity.PreparedByEmployeeID); Database.AddInParameter(cmd, "@PreparedByEmployeeSalaryLevel", DbType.Int32, hREmployeeNoticeEntity.PreparedByEmployeeSalaryLevel); Database.AddInParameter(cmd, "@TemplateID", DbType.Int64, hREmployeeNoticeEntity.TemplateID); Database.AddInParameter(cmd, "@SeenNotice", DbType.DateTime, hREmployeeNoticeEntity.SeenNotice); Database.AddInParameter(cmd, "@ViewCount", DbType.Int64, hREmployeeNoticeEntity.ViewCount); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeNoticeEntity already exists. Please specify another HREmployeeNoticeEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeNoticeEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeNoticeEntity already exists. Please specify another HREmployeeNoticeEntity."); } } } } return(returnCode); }
private HREmployeeNoticeEntity BuildHREmployeeNoticeEntity() { HREmployeeNoticeEntity hREmployeeNoticeEntity = CurrentHREmployeeNoticeEntity; if (ddlSendToEmployeeID.Items.Count > 0) { if (ddlSendToEmployeeID.SelectedValue == "0") { } else { hREmployeeNoticeEntity.SendToEmployeeID = Int64.Parse(ddlSendToEmployeeID.SelectedValue); } } if (!txtMemo.Text.Trim().IsNullOrEmpty()) { hREmployeeNoticeEntity.Memo = txtMemo.Text.Trim(); } else { hREmployeeNoticeEntity.Memo = null; } hREmployeeNoticeEntity.Text = txtText.Content.Trim(); hREmployeeNoticeEntity.Remarks = txtRemarks.Text.Trim(); if (txtNoticeDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeNoticeEntity.NoticeDate = MiscUtil.ParseToDateTime(txtNoticeDate.Text); } hREmployeeNoticeEntity.PreparedByEmployeeID = MiscUtil.GetCurrentEmployeeByMemberID(CurrentMember); hREmployeeNoticeEntity.PreparedByEmployeeSalaryLevel = null; if (ddlTemplateID.Items.Count > 0) { if (ddlTemplateID.SelectedValue == "0") { } else { hREmployeeNoticeEntity.TemplateID = Int64.Parse(ddlTemplateID.SelectedValue); } } hREmployeeNoticeEntity.ViewCount = 0; return(hREmployeeNoticeEntity); }
private void PrepareInitialView() { BuildDropDownList(); DateTime seenNotice = DateTime.Now.Date; Int64 viewCount = 1; HREmployeeNoticeEntity entity = CurrentHREmployeeNoticeEntity; lblNoticeTextView.Text = Server.HtmlDecode(CurrentHREmployeeNoticeEntity.Text.ToString()); if (CurrentHREmployeeNoticeEntity.ViewCount <= 0) { entity.SeenNotice = seenNotice; entity.ViewCount = viewCount; String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeNoticeEntity.FLD_NAME_EmployeeNoticeID, entity.EmployeeNoticeID.ToString(), SQLMatchType.Equal); FCCHREmployeeNotice.GetFacadeCreate().Update(entity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } }
private void SendMail(HREmployeeNoticeEntity noticeEntity) { HREmployeeNoticeEntity entity = noticeEntity; #region Notice Mail String MailBody = String.Empty; String Subject = String.Empty; StringBuilder sb = new StringBuilder(); sb.Append("Dear Sir,"); sb.Append("<br/>"); sb.Append("This is a auto generated mail from the ERP."); sb.Append("<br/>"); sb.Append("A " + entity.Memo + " Have Been send By HR. Please go to your profile and Check " + entity.Memo + "."); sb.Append("<br/>"); sb.Append("-"); sb.Append("<br/>"); sb.Append("Thanks"); sb.Append("<br/>"); sb.Append("ERP System"); MailBody = sb.ToString(); Subject = "ERP, Notice Reply"; String[] sendToMail = new String[1]; HREmployeeEntity _hREmployeeEntity = FCCHREmployee.GetFacadeCreate().GetByID(entity.SendToEmployeeID); if (_hREmployeeEntity != null) { sendToMail[0] = _hREmployeeEntity.PrimaryEmail; } MiscUtil.SendMail(sendToMail, Subject, MailBody); #endregion }
private Int64 Delete(HREmployeeNoticeEntity hREmployeeNoticeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeNotice_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeNoticeEntity already exists. Please specify another HREmployeeNoticeEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeNoticeEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeNoticeEntity already exists. Please specify another HREmployeeNoticeEntity."); } } } } return(returnCode); }
Int64 IHREmployeeNoticeFacade.Add(HREmployeeNoticeEntity hREmployeeNoticeEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeNoticeDataAccess().Add(hREmployeeNoticeEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeeNoticeID = 0; _HREmployeeNoticeEntity = new HREmployeeNoticeEntity(); PrepareInitialView(); }
Int64 IHREmployeeNoticeFacade.Delete(HREmployeeNoticeEntity hREmployeeNoticeEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeNoticeDataAccess().Delete(hREmployeeNoticeEntity, filterExpression, option, reqTran)); }