int validate_sctParam(SCT_UpdateInputEntity entry_BAL) { logger.Info("Method : validate_sctParam Start"); logger.DebugFormat("Input Parameter entry_BAL : EmpNo value = {0} and WEF = {1}", entry_BAL.EmpNo, entry_BAL.WEF); if (string.IsNullOrEmpty(entry_BAL.EmpNo)) { logger.Error("EmpNo has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.WEF)) { logger.Error("WEF has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentBU)) { logger.Error("CurrentBU has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewBU)) { logger.Error("NewBU has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentSBU)) { logger.Error("CurrentSBU has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewSBU)) { logger.Error("NewSBU has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentHorizontal)) { logger.Error("CurrentHorizontal has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewHorizontal)) { logger.Error("NewHorizontal has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentOrg)) { logger.Error("CurrentOrg has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewOrg)) { logger.Error("NewOrg has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentCost)) { logger.Error("CurrentCost has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewCost)) { logger.Error("NewCost has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentPersonal)) { logger.Error("CurrentPersonal has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewPersonal)) { logger.Error("NewPersonal has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentSubArea)) { logger.Error("CurrentSubArea has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewSubArea)) { logger.Error("NewSubArea has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentGrade)) { logger.Error("CurrentGrade has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewGrade)) { logger.Error("NewGrade has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.SubmittedBy)) { logger.Error("SubmittedBy has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrBLocation)) { logger.Error("CurrBLocation has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewBLocation)) { logger.Error("NewBLocation has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrBLocation)) { logger.Error("CurrBLocation has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrCDeploy)) { logger.Error("CurrCDeploy has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewCDeploy)) { logger.Error("NewCDeploy has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.CurrentSuperId)) { logger.Error("CurrentSuperId has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (string.IsNullOrEmpty(entry_BAL.NewSuperId)) { logger.Error("NewSuperId has NULL reference"); logger.Info("Method : validate_sctParam Stop"); return 1; } if (entry_BAL.CurrentSuperId.Equals(entry_BAL.NewSuperId)) { logger.Error("Current Supervisor Id is same as New Supervisor Id"); logger.Info("Method : validate_sctParam Stop"); return 1; } logger.Info("Method : validate_sctParam Stop"); return 0; }
/// <summary> /// This function Updates SCT Details into the Database /// </summary> /// <param name="is_entry_DAL"></param> /// <returns> /// <paramref name="result"/> /// </returns> /// <history> /// Hari haran 08/05/2012 created /// </history> public SCT_UpdateOutputEntity updateSCEmployeeDetails_DAL(SCT_UpdateInputEntity entry_DAL) { logger.Info("Method : updateSCEmployeeDetails_DAL Start"); logger.DebugFormat("Input Parameter entry_BAL : EmpNo value = {0} and WEF = {1}", entry_DAL.EmpNo, entry_DAL.WEF); databaseLayer dbConStr = new databaseLayer(); string connStr = dbConStr.connectionInfo; logger.Debug("Connection string : " + connStr); SqlConnection conn = new SqlConnection(connStr); SqlTransaction Trans = null; if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); logger.Debug("Connection Status opened "); } logger.Info("Connetion to the database established"); try { SCT_UpdateOutputEntity result = new SCT_UpdateOutputEntity(); SqlCommand insert_cmd = new SqlCommand(); insert_cmd.Connection = conn; insert_cmd.CommandType = CommandType.StoredProcedure; Trans = conn.BeginTransaction("InsertTransaction"); insert_cmd.Transaction = Trans; string insertQuery = "HRMSACInsertRequestChange"; insert_cmd.CommandText = insertQuery; insert_cmd.Parameters.AddWithValue("@EMPNO", Convert.ToInt32(entry_DAL.EmpNo)); insert_cmd.Parameters.AddWithValue("@REASON", entry_DAL.Reason); insert_cmd.Parameters.AddWithValue("@WEF", Convert.ToDateTime(entry_DAL.WEF).ToString()); insert_cmd.Parameters.AddWithValue("@CURRENTSBU", entry_DAL.CurrentBU); insert_cmd.Parameters.AddWithValue("@NEWSBU", entry_DAL.NewBU); insert_cmd.Parameters.AddWithValue("@CURRENTBU", entry_DAL.CurrentSBU); insert_cmd.Parameters.AddWithValue("@NEWBU", entry_DAL.NewSBU); insert_cmd.Parameters.AddWithValue("@CURRENTHORIZONTAL", entry_DAL.CurrentHorizontal); insert_cmd.Parameters.AddWithValue("@NEWHORIZONTAL", entry_DAL.NewHorizontal); insert_cmd.Parameters.AddWithValue("@CURRENTORG", entry_DAL.CurrentOrg); insert_cmd.Parameters.AddWithValue("@NEWORG", entry_DAL.NewOrg); insert_cmd.Parameters.AddWithValue("@CURRENTCOST", entry_DAL.CurrentCost); insert_cmd.Parameters.AddWithValue("@NEWCOST", entry_DAL.NewCost); insert_cmd.Parameters.AddWithValue("@CURRENTPERSONAL", entry_DAL.CurrentPersonal); insert_cmd.Parameters.AddWithValue("@NEWPERSONAL", entry_DAL.NewPersonal); insert_cmd.Parameters.AddWithValue("@CURRENTSUBAREA", entry_DAL.CurrentSubArea); insert_cmd.Parameters.AddWithValue("@NEWSUBAREA", entry_DAL.NewSubArea); insert_cmd.Parameters.AddWithValue("@CURRENTGRADE", entry_DAL.CurrentGrade); insert_cmd.Parameters.AddWithValue("@NEWGRADE", entry_DAL.NewGrade); insert_cmd.Parameters.AddWithValue("@CURRENTSUPPERID", Convert.ToInt32(entry_DAL.CurrentSuperId)); insert_cmd.Parameters.AddWithValue("@NEWSUPPERID", Convert.ToInt32(entry_DAL.NewSuperId)); insert_cmd.Parameters.AddWithValue("@SUBMMITEDCOMMENTS", entry_DAL.SubmittedComment); insert_cmd.Parameters.AddWithValue("@SUBMITTEDBY", Convert.ToInt32(entry_DAL.SubmittedBy)); insert_cmd.Parameters.AddWithValue("@SUBMITTEDFROMIP", DBNull.Value); insert_cmd.Parameters.AddWithValue("@STATUS", "S"); insert_cmd.Parameters.AddWithValue("@SUBMITTEDDATE", System.DateTime.Now.ToString("yyyy-MM-dd H:mm:ss.fff")); insert_cmd.Parameters.AddWithValue("@CURRENTET_PLACE", entry_DAL.CurrBLocation); insert_cmd.Parameters.AddWithValue("@NEWET_PLACE", entry_DAL.NewBLocation); insert_cmd.Parameters.AddWithValue("@REPORTING_TYPE", 'O'); insert_cmd.Parameters.AddWithValue("@CUR_CENTER_DEPLOYMENT", entry_DAL.CurrCDeploy); insert_cmd.Parameters.AddWithValue("@NEW_CENTER_DEPLOYMENT", entry_DAL.NewCDeploy); logger.Info("Inserting Details of SCT UpdateInput Entity"); QueryLog.CmdInfo(insert_cmd); //SqlDataReader dr; int rowsAffected = insert_cmd.ExecuteNonQuery(); //if (dr.HasRows) if (rowsAffected == 1) { //dr.Read(); //if (dr["Return Value"].Equals(0)) //{ //dr.Close(); Trans.Commit(); result.StatusFlag = 0; result.Message = SCT_Constants.Success; logger.Info("Operation : Insert operation executed successfully"); } else { //dr.Close(); Trans.Rollback("InsertTransaction"); logger.Debug("Transaction Rollback Executed"); result.StatusFlag = 1; result.Message = SCT_Constants.Error; logger.Error("Operation : Insert operation Failed"); } return result; } catch (SqlException dbEx) { logger.Fatal("SQL Exception Occured At SCT_DAL - updatePurchaseRequest_DAL : "); logger.Error("Exception Code : " + dbEx.Number.ToString()); logger.Error("Exception Description : " + dbEx.Message.ToString()); logger.Error("Error : updateSCEmployeeDetails_DAL Stop"); try { logger.Debug("Transaction Rollback Executed"); Trans.Rollback("InsertTransaction"); } catch (Exception ex2) { logger.Error("Tranasction Rollback Failed : " + ex2.Message.ToString()); //throw ex2; } throw dbEx; } catch (Exception ex) { logger.Fatal("Exception Occured At SCT_DAL - updateSCEmployeeDetails_DAL : " + ex.Message.ToString()); logger.Error("Method : updateSCEmployeeDetails_DAL Stop"); try { logger.Debug("Transaction Rollback Executed"); Trans.Rollback("InsertTransaction"); } catch (Exception ex2) { logger.Error("Transaction Rollback Failed : "+ex2.Message.ToString()); //throw ex2; } //throw new myCustomException(32, ex.Message); throw ex; } finally { logger.Debug("Connection Status Closed "); conn.Dispose(); } }
/// <summary> /// This Method validates the input parameters for the updatePurchaseRequest function /// </summary> /// <param name="entry_BAL"></param> /// <returns></returns> /// <history> /// Hari haran 08/05/2012 created /// </history> public SCT_UpdateOutputEntity updateSCEmployeeDetails_BAL(SCT_UpdateInputEntity entry_BAL) { try { logger.Info("Method : updateSCEmployeeDetails_BAL Start"); logger.Debug("Method : updateSCEmployeeDetails_BAL RequestId value : " + entry_BAL.EmpNo.ToString()); SCT_UpdateOutputEntity errRes = new SCT_UpdateOutputEntity(); errRes.StatusFlag = 1; errRes.Message = SCT_Constants.Error; int validate_sctParamFlag = 0; validate_sctParamFlag = validate_sctParam(entry_BAL); logger.Debug("SCT Input parameter validation flag value(success = 0/failure = 1) : " + validate_sctParamFlag.ToString()); if (validate_sctParamFlag == 1) { logger.Debug("Error in input parameter values"); logger.Debug("ErrorCode = " + errRes.StatusFlag.ToString()); logger.Debug("ErrorMessage = " + errRes.Message); logger.Error("Method : updateSCEmployeeDetails_BAL Stop"); return errRes; } else { SCT_DAL updateSCT_DAL = new SCT_DAL(); return (updateSCT_DAL.updateSCEmployeeDetails_DAL(entry_BAL)); } } catch (SqlException dbEx) { logger.Fatal("Exception At BAL - updateSCEmployeeDetails_BAL : " + dbEx.Message.ToString()); logger.Error("Method : updateSCEmployeeDetails_BAL Stop"); throw dbEx; } catch (Exception ex) { logger.Fatal("Exception At BAL - updateSCEmployeeDetails_BAL : " + ex.Message.ToString()); logger.Error("Method : updateSCEmployeeDetails_BAL Stop"); throw ex; } }
/*****************************************************************************/ /// <summary> /// This Method is a interface to updatePurchaseRequest fuction /// </summary> /// <param name="entry_SI"></param> /// <returns></returns> /// /// <history> /// Hari haran 08/05/2012 created /// </history> public SCT_UpdateOutputEntity updateSCEmployeeDetails_SI(SCT_UpdateInputEntity entry_SI) { try { logger.Info("Control Flow : Method - updateSCEmployeeDetails_SI Start"); logger.Debug("EmployeeID value : " + entry_SI.EmpNo.ToString()); SCT_BAL updateTS_BAL = new SCT_BAL(); return (updateTS_BAL.updateSCEmployeeDetails_BAL(entry_SI)); } catch (SqlException dbEx) { logger.Fatal("Database Exception At SCTInterface - updateSCEmployeeDetails_SI : " + dbEx.Message.ToString()); logger.Error("Control Flow : Method - updateSCEmployeeDetails_SI Stop"); throw dbEx; } catch (Exception ex) { logger.Fatal("Exception At SCTInterface - updateSCEmployeeDetails_SI : " + ex.Message.ToString()); logger.Error("Control Flow : Method - updateSCEmployeeDetails_SI Stop"); throw ex; } }