Int64 ICMNApprovalPanelDataAccess.Add(CMNApprovalPanelEntity cMNApprovalPanelEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cMNApprovalPanelEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cMNApprovalPanelEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private CMNApprovalPanelEntity BuildCMNApprovalPanelEntity() { CMNApprovalPanelEntity cMNApprovalPanelEntity = CurrentCMNApprovalPanelEntity; if (ddlApprovalProcessID.Items.Count > 0) { if (ddlApprovalProcessID.SelectedValue == "0") { } else { cMNApprovalPanelEntity.ApprovalProcessID = Int64.Parse(ddlApprovalProcessID.SelectedValue); } } if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { cMNApprovalPanelEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } if (!txtSequeenceNo.Text.Trim().IsNullOrEmpty()) { cMNApprovalPanelEntity.SequeenceNo = Int32.Parse(txtSequeenceNo.Text.Trim()); } if (ddlApprovalPanelStatusID.Items.Count > 0) { if (ddlApprovalPanelStatusID.SelectedValue == "0") { } else { cMNApprovalPanelEntity.ApprovalPanelStatusID = Int64.Parse(ddlApprovalPanelStatusID.SelectedValue); } } cMNApprovalPanelEntity.Remarks = txtRemarks.Text.Trim(); if (txtRequestDate.Text.Trim().IsNotNullOrEmpty()) { cMNApprovalPanelEntity.RequestDate = MiscUtil.ParseToDateTime(txtRequestDate.Text); } if (txtResponseDate.Text.Trim().IsNotNullOrEmpty()) { cMNApprovalPanelEntity.ResponseDate = MiscUtil.ParseToDateTime(txtResponseDate.Text); } else { cMNApprovalPanelEntity.ResponseDate = null; } return(cMNApprovalPanelEntity); }
private void PrepareEditView() { CMNApprovalPanelEntity cMNApprovalPanelEntity = CurrentCMNApprovalPanelEntity; if (!cMNApprovalPanelEntity.IsNew) { if (ddlApprovalProcessID.Items.Count > 0 && cMNApprovalPanelEntity.ApprovalProcessID != null) { ddlApprovalProcessID.SelectedValue = cMNApprovalPanelEntity.ApprovalProcessID.ToString(); } if (ddlEmployeeID.Items.Count > 0 && cMNApprovalPanelEntity.EmployeeID != null) { ddlEmployeeID.SelectedValue = cMNApprovalPanelEntity.EmployeeID.ToString(); } txtSequeenceNo.Text = cMNApprovalPanelEntity.SequeenceNo.ToString(); if (ddlApprovalPanelStatusID.Items.Count > 0 && cMNApprovalPanelEntity.ApprovalPanelStatusID != null) { ddlApprovalPanelStatusID.SelectedValue = cMNApprovalPanelEntity.ApprovalPanelStatusID.ToString(); } txtRemarks.Text = cMNApprovalPanelEntity.Remarks.ToString(); txtRequestDate.Text = cMNApprovalPanelEntity.RequestDate.ToStringDefault(); txtResponseDate.Text = cMNApprovalPanelEntity.ResponseDate.ToStringDefault(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 UpdateTran(CMNApprovalPanelEntity cMNApprovalPanelEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNApprovalPanel_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, "@ApprovalPanelID", DbType.Int64, cMNApprovalPanelEntity.ApprovalPanelID); db.AddInParameter(cmd, "@ApprovalProcessID", DbType.Int64, cMNApprovalPanelEntity.ApprovalProcessID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, cMNApprovalPanelEntity.EmployeeID); db.AddInParameter(cmd, "@SequeenceNo", DbType.Int32, cMNApprovalPanelEntity.SequeenceNo); db.AddInParameter(cmd, "@ApprovalPanelStatusID", DbType.Int64, cMNApprovalPanelEntity.ApprovalPanelStatusID); db.AddInParameter(cmd, "@Remarks", DbType.String, cMNApprovalPanelEntity.Remarks); db.AddInParameter(cmd, "@RequestDate", DbType.DateTime, cMNApprovalPanelEntity.RequestDate); db.AddInParameter(cmd, "@ResponseDate", DbType.DateTime, cMNApprovalPanelEntity.ResponseDate); 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 void SaveCMNApprovalPanelEntity() { if (IsValid) { try { CMNApprovalPanelEntity cMNApprovalPanelEntity = BuildCMNApprovalPanelEntity(); Int64 result = -1; if (cMNApprovalPanelEntity.IsNew) { result = FCCCMNApprovalPanel.GetFacadeCreate().Add(cMNApprovalPanelEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMNApprovalPanelEntity.FLD_NAME_ApprovalPanelID, cMNApprovalPanelEntity.ApprovalPanelID.ToString(), SQLMatchType.Equal); result = FCCCMNApprovalPanel.GetFacadeCreate().Update(cMNApprovalPanelEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _ApprovalPanelID = 0; _CMNApprovalPanelEntity = new CMNApprovalPanelEntity(); PrepareInitialView(); BindCMNApprovalPanelList(); if (cMNApprovalPanelEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C MNApproval Panel Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C MNApproval Panel Information has been updated successfully.", false); } } else { if (cMNApprovalPanelEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C MNApproval Panel Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C MNApproval Panel Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvCMNApprovalPanel_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 ApprovalPanelID; Int64.TryParse(e.CommandArgument.ToString(), out ApprovalPanelID); if (ApprovalPanelID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _ApprovalPanelID = ApprovalPanelID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CMNApprovalPanelEntity.FLD_NAME_ApprovalPanelID, ApprovalPanelID.ToString(), SQLMatchType.Equal); CMNApprovalPanelEntity cMNApprovalPanelEntity = new CMNApprovalPanelEntity(); result = FCCCMNApprovalPanel.GetFacadeCreate().Delete(cMNApprovalPanelEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _ApprovalPanelID = 0; _CMNApprovalPanelEntity = new CMNApprovalPanelEntity(); PrepareInitialView(); BindCMNApprovalPanelList(); MiscUtil.ShowMessage(lblMessage, "C MNApproval Panel has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C MNApproval Panel.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CMNApprovalPanelEntity cMNApprovalPanelEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNApprovalPanel_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(CMNApprovalPanelEntity cMNApprovalPanelEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNApprovalPanel_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@ApprovalPanelID", DbType.Int64, cMNApprovalPanelEntity.ApprovalPanelID); Database.AddInParameter(cmd, "@ApprovalProcessID", DbType.Int64, cMNApprovalPanelEntity.ApprovalProcessID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, cMNApprovalPanelEntity.EmployeeID); Database.AddInParameter(cmd, "@SequeenceNo", DbType.Int32, cMNApprovalPanelEntity.SequeenceNo); Database.AddInParameter(cmd, "@ApprovalPanelStatusID", DbType.Int64, cMNApprovalPanelEntity.ApprovalPanelStatusID); Database.AddInParameter(cmd, "@Remarks", DbType.String, cMNApprovalPanelEntity.Remarks); Database.AddInParameter(cmd, "@RequestDate", DbType.DateTime, cMNApprovalPanelEntity.RequestDate); Database.AddInParameter(cmd, "@ResponseDate", DbType.DateTime, cMNApprovalPanelEntity.ResponseDate); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CMNApprovalPanelEntity already exists. Please specify another CMNApprovalPanelEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMNApprovalPanelEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMNApprovalPanelEntity already exists. Please specify another CMNApprovalPanelEntity."); } } } } return(returnCode); }
private Int64 Delete(CMNApprovalPanelEntity cMNApprovalPanelEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNApprovalPanel_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("CMNApprovalPanelEntity already exists. Please specify another CMNApprovalPanelEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMNApprovalPanelEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMNApprovalPanelEntity already exists. Please specify another CMNApprovalPanelEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _ApprovalPanelID = 0; _CMNApprovalPanelEntity = new CMNApprovalPanelEntity(); PrepareInitialView(); }
Int64 ICMNApprovalPanelFacade.Delete(CMNApprovalPanelEntity cMNApprovalPanelEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMNApprovalPanelDataAccess().Delete(cMNApprovalPanelEntity, filterExpression, option, reqTran)); }
Int64 ICMNApprovalPanelFacade.Add(CMNApprovalPanelEntity cMNApprovalPanelEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMNApprovalPanelDataAccess().Add(cMNApprovalPanelEntity, option, reqTran)); }