Int64 IMDEmployeeSkillDataAccess.Add(MDEmployeeSkillEntity mDEmployeeSkillEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(mDEmployeeSkillEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(mDEmployeeSkillEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveMDEmployeeSkillEntity() { if (IsValid) { try { MDEmployeeSkillEntity mDEmployeeSkillEntity = BuildMDEmployeeSkillEntity(); Int64 result = -1; if (mDEmployeeSkillEntity.IsNew) { result = FCCMDEmployeeSkill.GetFacadeCreate().Add(mDEmployeeSkillEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDEmployeeSkillEntity.FLD_NAME_EmployeeSkillID, mDEmployeeSkillEntity.EmployeeSkillID.ToString(), SQLMatchType.Equal); result = FCCMDEmployeeSkill.GetFacadeCreate().Update(mDEmployeeSkillEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeSkillID = 0; _MDEmployeeSkillEntity = new MDEmployeeSkillEntity(); PrepareInitialView(); BindMDEmployeeSkillList(); if (mDEmployeeSkillEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Skill Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Skill Information has been updated successfully.", false); } } else { if (mDEmployeeSkillEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Skill Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Skill Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private MDEmployeeSkillEntity BuildMDEmployeeSkillEntity() { MDEmployeeSkillEntity mDEmployeeSkillEntity = CurrentMDEmployeeSkillEntity; mDEmployeeSkillEntity.Name = txtName.Text.Trim(); mDEmployeeSkillEntity.Description = txtDescription.Text.Trim(); mDEmployeeSkillEntity.IsRemoved = chkIsRemoved.Checked; return(mDEmployeeSkillEntity); }
private Int64 UpdateTran(MDEmployeeSkillEntity mDEmployeeSkillEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDEmployeeSkill_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, "@EmployeeSkillID", DbType.Int64, mDEmployeeSkillEntity.EmployeeSkillID); db.AddInParameter(cmd, "@Name", DbType.String, mDEmployeeSkillEntity.Name); db.AddInParameter(cmd, "@Description", DbType.String, mDEmployeeSkillEntity.Description); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDEmployeeSkillEntity.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); }
protected void lvMDEmployeeSkill_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeeSkillID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeeSkillID); if (EmployeeSkillID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeeSkillID = EmployeeSkillID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(MDEmployeeSkillEntity.FLD_NAME_EmployeeSkillID, EmployeeSkillID.ToString(), SQLMatchType.Equal); MDEmployeeSkillEntity mDEmployeeSkillEntity = new MDEmployeeSkillEntity(); result = FCCMDEmployeeSkill.GetFacadeCreate().Delete(mDEmployeeSkillEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeeSkillID = 0; _MDEmployeeSkillEntity = new MDEmployeeSkillEntity(); PrepareInitialView(); BindMDEmployeeSkillList(); MiscUtil.ShowMessage(lblMessage, "Employee Skill has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Skill.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private void PrepareEditView() { MDEmployeeSkillEntity mDEmployeeSkillEntity = CurrentMDEmployeeSkillEntity; if (!mDEmployeeSkillEntity.IsNew) { txtName.Text = mDEmployeeSkillEntity.Name.ToString(); txtDescription.Text = mDEmployeeSkillEntity.Description.ToString(); chkIsRemoved.Checked = mDEmployeeSkillEntity.IsRemoved; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Update(MDEmployeeSkillEntity mDEmployeeSkillEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.MDEmployeeSkill_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeeSkillID", DbType.Int64, mDEmployeeSkillEntity.EmployeeSkillID); Database.AddInParameter(cmd, "@Name", DbType.String, mDEmployeeSkillEntity.Name); Database.AddInParameter(cmd, "@Description", DbType.String, mDEmployeeSkillEntity.Description); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDEmployeeSkillEntity.IsRemoved); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("MDEmployeeSkillEntity already exists. Please specify another MDEmployeeSkillEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("MDEmployeeSkillEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("MDEmployeeSkillEntity already exists. Please specify another MDEmployeeSkillEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeeSkillID = 0; _MDEmployeeSkillEntity = new MDEmployeeSkillEntity(); PrepareInitialView(); }
Int64 IMDEmployeeSkillFacade.Delete(MDEmployeeSkillEntity mDEmployeeSkillEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDEmployeeSkillDataAccess().Delete(mDEmployeeSkillEntity, filterExpression, option, reqTran)); }
Int64 IMDEmployeeSkillFacade.Add(MDEmployeeSkillEntity mDEmployeeSkillEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateMDEmployeeSkillDataAccess().Add(mDEmployeeSkillEntity, option, reqTran)); }