public int InsertEmployee(EmployeeBDto ObjEmployeeBDto) { Database db = null; DbCommand dbCmd = null; DataSet ds = null; int Result = 0; try { db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING); dbCmd = db.GetStoredProcCommand(DALHelper.USP_HR_EMPLOYEE_INSERT); db.AddInParameter(dbCmd, "@EMP_TITLE_ID", DbType.Int32, ObjEmployeeBDto.TitleId); db.AddInParameter(dbCmd, "@EMP_SURNAME", DbType.String, ObjEmployeeBDto.EmpSurName); db.AddInParameter(dbCmd, "@EMP_NAME", DbType.String, ObjEmployeeBDto.EmpName); // db.AddInParameter(dbCmd, "@EMP_DESIGNATION_ID", DbType.Int32, ObjEmployeeBDto.DesignationId); // db.AddInParameter(dbCmd, "@EMP_DEPARTMENT_ID", DbType.Int32, ObjEmployeeBDto.DepartmentId); db.AddInParameter(dbCmd, "@EMP_DOB", DbType.DateTime, ObjEmployeeBDto.DateofBirth); db.AddInParameter(dbCmd, "@EMP_MARITAL_STATUS", DbType.Int32, ObjEmployeeBDto.MaritalStatusId); db.AddInParameter(dbCmd, "@EMP_GENDER", DbType.String, ObjEmployeeBDto.Gender); // db.AddInParameter(dbCmd, "@EMP_MANAGE_ID", DbType.Int32, ObjEmployeeBDto.ManageId); db.AddInParameter(dbCmd, "@EMP_EMAIL", DbType.String, ObjEmployeeBDto.Email); db.AddInParameter(dbCmd, "@EMP_MOBILE", DbType.String, ObjEmployeeBDto.Mobile); db.AddInParameter(dbCmd, "@EMP_PHONE", DbType.String, ObjEmployeeBDto.Phone); db.AddInParameter(dbCmd, "@EMP_QUALIFICATION_ID", DbType.Int32, ObjEmployeeBDto.QualificationId); // db.AddInParameter(dbCmd, "@EMP_DOJ", DbType.DateTime, ObjEmployeeBDto.DateofJoin); db.AddInParameter(dbCmd, "@EMP_STATUS", DbType.Int32, ObjEmployeeBDto.StatusId); db.AddInParameter(dbCmd, "@PHOTO", DbType.Binary, ObjEmployeeBDto.Photo); db.AddInParameter(dbCmd, "@PHOTO_CONTENT_TYPE", DbType.String, ObjEmployeeBDto.Phototype); db.AddInParameter(dbCmd, "@SIGNATURE1", DbType.String, ObjEmployeeBDto.Signature1); db.AddInParameter(dbCmd, "@SIGNATURE2", DbType.String, ObjEmployeeBDto.Signature2); db.AddInParameter(dbCmd, "@SIGNATURE3", DbType.String, ObjEmployeeBDto.Signature3); db.AddInParameter(dbCmd, "@USER_ID", DbType.Int32, ObjEmployeeBDto.UserId); db.AddOutParameter(dbCmd, "@IS_INSERT", DbType.Int32, 1); ds = db.ExecuteDataSet(dbCmd); Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@IS_INSERT")); return Result; } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } finally { DALHelper.Destroy(ref dbCmd); } return 0; }
public int UpdateEmployeeProfile(EmployeeBDto ObjEmployeeBDto) { Database db = null; DbCommand dbCmd = null; int Result = 0; try { db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING); dbCmd = db.GetStoredProcCommand(DALHelper.USP_HR_EMPLOYEE_PROFILE_UPDATE); // db.AddInParameter(dbCmd, "@EMP_TITLE_ID", DbType.Int32, ObjEmployeeBDto.TitleId); db.AddInParameter(dbCmd, "@EMP_MARITAL_STATUS", DbType.Int32, ObjEmployeeBDto.MaritalStatusId); db.AddInParameter(dbCmd, "@EMP_EMAIL", DbType.String, ObjEmployeeBDto.Email); db.AddInParameter(dbCmd, "@EMP_MOBILE", DbType.String, ObjEmployeeBDto.Mobile); db.AddInParameter(dbCmd, "@EMP_PHONE", DbType.String, ObjEmployeeBDto.Phone); db.AddInParameter(dbCmd, "@EMP_QUALIFICATION_ID", DbType.Int32, ObjEmployeeBDto.QualificationId); db.AddInParameter(dbCmd, "@EMP_ID", DbType.Int32, ObjEmployeeBDto.EmpId); db.AddInParameter(dbCmd, "@EMP_DOB", DbType.DateTime, ObjEmployeeBDto.DateofBirth); db.AddInParameter(dbCmd, "@EMP_GENDER", DbType.String, ObjEmployeeBDto.Gender); db.AddOutParameter(dbCmd, "@IS_UPDATE", DbType.Int32, 1); Result = db.ExecuteNonQuery(dbCmd); Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@IS_UPDATE")); if (db.GetParameterValue(dbCmd, "@IS_UPDATE") != DBNull.Value) Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@IS_UPDATE")); if (Result == 1) return 1; // SUCCESSFUL INSERTION RETURN TRUE else return 0; // UNSUCCESSFUL INSERTION RETUN FALSE ( ALREADY EXISTS ) } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } finally { DALHelper.Destroy(ref dbCmd); } return 0; }
protected void btnSaveInfo_Click(object sender, EventArgs e) { int result = 0; objEmployeeMasterDal = new EmployeeMasterDal(); EmployeeBDto objEmployeeBDto = new EmployeeBDto(); // objEmployeeBDto.TitleId = Convert.ToInt32(radCmbTitleAdd.SelectedValue); objEmployeeBDto.MaritalStatusId = Convert.ToInt32(radCmbMaritalStatusAdd.SelectedValue); objEmployeeBDto.QualificationId = Convert.ToInt32(radCmbQualificationAdd.SelectedValue); objEmployeeBDto.Mobile = txteditMobile.Text; objEmployeeBDto.Phone = txtEditPhone.Text; objEmployeeBDto.Email = txtEditEmail.Text; objEmployeeBDto.EmpId = Convert.ToInt32(Session["EmpId"]); objEmployeeBDto.DateofBirth = RadDateDobAdd.SelectedDate.Value; ; objEmployeeBDto.Gender = rblstPerGender.SelectedValue; ; result = objEmployeeMasterDal.UpdateEmployeeProfile(objEmployeeBDto); if (result == 1) { rblstPerGender.ClearSelection(); ViewState["Profile"] = null; Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString()); Master.MessageCssClass = "successMessage"; GetEmployeeDetails(); pnlEditInfo.Visible = false; pnlDisplayInfo.Visible = true; } else { Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString()); Master.MessageCssClass = "errorMessage"; } }