Int64 ICMNFavoriteDataAccess.Delete(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(cMNFavoriteEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(cMNFavoriteEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 ICMNFavoriteDataAccess.Add(CMNFavoriteEntity cMNFavoriteEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cMNFavoriteEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cMNFavoriteEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private CMNFavoriteEntity BuildCMNFavoriteEntity() { CMNFavoriteEntity cMNFavoriteEntity = CurrentCMNFavoriteEntity; if (ddlProcessCategoryID.Items.Count > 0) { if (ddlProcessCategoryID.SelectedValue == "0") { } else { cMNFavoriteEntity.ProcessCategoryID = Int64.Parse(ddlProcessCategoryID.SelectedValue); } } if (!txtReferenceID.Text.Trim().IsNullOrEmpty()) { cMNFavoriteEntity.ReferenceID = Int64.Parse(txtReferenceID.Text.Trim()); } cMNFavoriteEntity.Remarks = txtRemarks.Text.Trim(); cMNFavoriteEntity.IsRemoved = chkIsRemoved.Checked; return(cMNFavoriteEntity); }
private Int64 UpdateTran(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNFavorite_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, "@FavoriteID", DbType.Int64, cMNFavoriteEntity.FavoriteID); db.AddInParameter(cmd, "@ProcessCategoryID", DbType.Int64, cMNFavoriteEntity.ProcessCategoryID); db.AddInParameter(cmd, "@ReferenceID", DbType.Int64, cMNFavoriteEntity.ReferenceID); db.AddInParameter(cmd, "@Remarks", DbType.String, cMNFavoriteEntity.Remarks); db.AddInParameter(cmd, "@FavoriteDate", DbType.DateTime, cMNFavoriteEntity.FavoriteDate); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, cMNFavoriteEntity.EmployeeID); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cMNFavoriteEntity.IsRemoved); 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 SaveCMNFavoriteEntity() { if (IsValid) { try { CMNFavoriteEntity cMNFavoriteEntity = BuildCMNFavoriteEntity(); Int64 result = -1; if (cMNFavoriteEntity.IsNew) { result = FCCCMNFavorite.GetFacadeCreate().Add(cMNFavoriteEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMNFavoriteEntity.FLD_NAME_FavoriteID, cMNFavoriteEntity.FavoriteID.ToString(), SQLMatchType.Equal); result = FCCCMNFavorite.GetFacadeCreate().Update(cMNFavoriteEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _FavoriteID = 0; _CMNFavoriteEntity = new CMNFavoriteEntity(); PrepareInitialView(); BindCMNFavoriteList(); if (cMNFavoriteEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "C MNFavorite Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "C MNFavorite Information has been updated successfully.", false); } } else { if (cMNFavoriteEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add C MNFavorite Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update C MNFavorite Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvCMNFavorite_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 FavoriteID; Int64.TryParse(e.CommandArgument.ToString(), out FavoriteID); if (FavoriteID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _FavoriteID = FavoriteID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CMNFavoriteEntity.FLD_NAME_FavoriteID, FavoriteID.ToString(), SQLMatchType.Equal); CMNFavoriteEntity cMNFavoriteEntity = new CMNFavoriteEntity(); result = FCCCMNFavorite.GetFacadeCreate().Delete(cMNFavoriteEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _FavoriteID = 0; _CMNFavoriteEntity = new CMNFavoriteEntity(); PrepareInitialView(); BindCMNFavoriteList(); MiscUtil.ShowMessage(lblMessage, "C MNFavorite has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C MNFavorite.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNFavorite_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(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNFavorite_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@FavoriteID", DbType.Int64, cMNFavoriteEntity.FavoriteID); Database.AddInParameter(cmd, "@ProcessCategoryID", DbType.Int64, cMNFavoriteEntity.ProcessCategoryID); Database.AddInParameter(cmd, "@ReferenceID", DbType.Int64, cMNFavoriteEntity.ReferenceID); Database.AddInParameter(cmd, "@Remarks", DbType.String, cMNFavoriteEntity.Remarks); Database.AddInParameter(cmd, "@FavoriteDate", DbType.DateTime, cMNFavoriteEntity.FavoriteDate); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, cMNFavoriteEntity.EmployeeID); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cMNFavoriteEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CMNFavoriteEntity already exists. Please specify another CMNFavoriteEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMNFavoriteEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMNFavoriteEntity already exists. Please specify another CMNFavoriteEntity."); } } } } return(returnCode); }
private void PrepareEditView() { CMNFavoriteEntity cMNFavoriteEntity = CurrentCMNFavoriteEntity; if (!cMNFavoriteEntity.IsNew) { if (ddlProcessCategoryID.Items.Count > 0 && cMNFavoriteEntity.ProcessCategoryID != null) { ddlProcessCategoryID.SelectedValue = cMNFavoriteEntity.ProcessCategoryID.ToString(); } txtReferenceID.Text = cMNFavoriteEntity.ReferenceID.ToString(); txtRemarks.Text = cMNFavoriteEntity.Remarks.ToString(); chkIsRemoved.Checked = cMNFavoriteEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Delete(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CMNFavorite_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("CMNFavoriteEntity already exists. Please specify another CMNFavoriteEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CMNFavoriteEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CMNFavoriteEntity already exists. Please specify another CMNFavoriteEntity."); } } } } return(returnCode); }
Int64 ICMNFavoriteFacade.Delete(CMNFavoriteEntity cMNFavoriteEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMNFavoriteDataAccess().Delete(cMNFavoriteEntity, filterExpression, option, reqTran)); }
Int64 ICMNFavoriteFacade.Add(CMNFavoriteEntity cMNFavoriteEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCMNFavoriteDataAccess().Add(cMNFavoriteEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _FavoriteID = 0; _CMNFavoriteEntity = new CMNFavoriteEntity(); PrepareInitialView(); }