/// <summary> /// author : [email protected] /// description : for approver re-activate /// </summary> /// <returns>JSON string "Good"</returns> /// INACTIVEAPPROVER @ver 1.0 @author rherejias 1/18/2017 public JsonResult ActiveApprover() { try { approverObj.Id = Convert.ToInt32(Request["id"]); approverObj.Code = Request["code"].ToString(); approverObj.DateAdded = DateTime.Now; approverObj.AddedBy = Convert.ToInt32(Session["userId_local"]); approverObj.IP = CustomHelper.GetLocalIPAddress(); approverObj.MAC = CustomHelper.GetMACAddress(); approver_model.ActiveApprover(approverObj); response.Add("success", true); response.Add("error", false); response.Add("message", "Record deactivation successfully!"); } catch (Exception e) { response.Add("success", false); response.Add("error", true); response.Add("message", e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }
/// <summary> /// for override reject /// </summary> /// <returns>response if success or not</returns> /// @ver @author rherejias 2/10/2017 public JsonResult Reject() { try { approverLog.Id = Convert.ToInt32(Request["id"]); approverLog.TransHeaderCode = Request["headercode"].ToString(); approverLog.IsApproved = false; approverLog.RejectedBy = Convert.ToInt32(Session["userId_local"]); approverLog.DateRejected = DateTime.Now; approverLog.IsOverride = true; approverLog.Remarks = Request["remarks"].ToString(); approverLog.IP = CustomHelper.GetLocalIPAddress(); approverLog.MAC = CustomHelper.GetMACAddress(); overrideModels.Reject(approverLog); response.Add("success", true); response.Add("error", false); response.Add("message", "Record added successfully!"); } catch (Exception e) { response.Add("success", false); response.Add("error", true); response.Add("message", e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult AssignApprover() { try { approverObj.Code = Request["code"].ToString(); approverObj.Module = Request["module"].ToString(); approverObj.ApprovalTypeCode = Request["type"].ToString(); approverObj.DepartmentCode = Request["department"].ToString(); approverObj.Id = Convert.ToInt32(Request["id"]); approverObj.DateAdded = DateTime.Now; approverObj.AddedBy = Convert.ToInt32(Session["userId_local"]); approverObj.IP = CustomHelper.GetLocalIPAddress(); approverObj.MAC = CustomHelper.GetMACAddress(); departmentApprover_model.AssignApprover(approverObj); response.Add(key: "success", value: true); response.Add(key: "error", value: false); response.Add(key: "message", value: ""); } catch (Exception e) { response.Add(key: "success", value: false); response.Add(key: "error", value: true); response.Add(key: "message", value: e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }
}// End #endregion /// <summary> /// desc: update the gatepass status to approved and return slip to not returned /// by: [email protected] /// date: january 23, 2017 /// </summary> /// <returns></returns> #region GuardApproved public JsonResult GuardApproved() { try { string headercode = Request["Id"].ToString(); string returndate = Request["returndate"].ToString(); ViewBag.headercodeOwnerId = guardModel.GetOwnerofHeader(headercode); string[] headercodeOwnerEmail = { guardModel.GetOwnerofHeaderEmail(ViewBag.headercodeOwnerId) }; string[] accountingEmail = { guardModel.GetAccountingEmail(headercode), ConfigurationManager.AppSettings["ampiguard_email"] }; string comment = ""; int guardIdLocal = Convert.ToInt32(Session["userId_local"]); string guardRights = Session["Department"].ToString(); string guradCode = Session["user_code"].ToString(); string guradname = Session["cn"].ToString(); string guardDateAdded = DateTime.Now.ToString(); bool guardIsApproved = true; guardModel.GatePassApproved(headercode, comment, guardIdLocal, guardRights, guradCode, guradname, guardDateAdded, guardIsApproved, returndate); // used for audit trail purposes auditObj.ProjectCode = "GAT"; // jira story name auditObj.Module = "GUARD"; // module transacted auditObj.Operation = "Approve"; //action inside the module auditObj.Object = "tblTransactionHeaders"; // table name transacted auditObj.ObjectId = Convert.ToInt32(Request["IdNumber"]); auditObj.ObjectCode = Request["Id"].ToString(); auditObj.UserCode = Convert.ToInt32(Session["userId_local"]); auditObj.IP = CustomHelper.GetLocalIPAddress(); auditObj.MAC = CustomHelper.GetMACAddress(); auditObj.DateAdded = DateTime.Now; auditModels.AddAuditTrail(auditObj); var emailMod = new EmailModels(); string emailContent = EmailContent(headercode); if (!SendEmailApprovedByGuard(emailContent, headercodeOwnerEmail, accountingEmail, headercode)) { throw new Exception(message: "Email not sent."); } response.Add(key: "success", value: true); response.Add(key: "error", value: false); response.Add(key: "message", value: " "); } catch (Exception e) { response.Add(key: "success", value: false); response.Add(key: "error", value: true); response.Add(key: "message", value: e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }// End
/// <summary> /// for adding of data in approvallogs table /// </summary> /// <param name="row"> specify row data</param> /// <param name="dateToday">date today</param> /// <param name="code">null</param> /// <param name="remarks">remarks for overriding data</param> /// <returns>boolean true or false</returns> /// @ver @author rherejias 2/10/2017 public bool overrideFunction(DataRow row, DateTime dateToday, string code, string remarks) { approverLog.Id = Convert.ToInt32(row["Id"]); approverLog.Code = code; approverLog.IsApproved = true; approverLog.ApprovedBy = Convert.ToInt32(Session["userId_local"]); approverLog.DateApproved = dateToday; approverLog.Remarks = remarks; approverLog.IsOverride = true; approverLog.IP = CustomHelper.GetLocalIPAddress(); approverLog.MAC = CustomHelper.GetMACAddress(); return(overrideModels.Override(approverLog)); }
/// <summary> /// author : [email protected] /// description : for approver inactive /// </summary> /// <returns>JSON string "Good"</returns> /// INACTIVEAPPROVER @ver 1.0 @author rherejias 1/5/2017 /// INACTIVEAPPROVER @ver 2.0 @author rherejias 1/16/2017 *added audit trail function public JsonResult inactiveApprover() { try { approverObj.Id = Convert.ToInt32(Request["id"]); approverObj.Code = Request["code"].ToString(); approverObj.ApprovalTypeCode = Request["approverType"].ToString(); approverObj.DateAdded = DateTime.Now; approverObj.AddedBy = Convert.ToInt32(Session["userId_local"]); approverObj.IP = CustomHelper.GetLocalIPAddress(); approverObj.MAC = CustomHelper.GetMACAddress(); if (approverObj.ApprovalTypeCode == ConfigurationManager.AppSettings["itApprover"] || approverObj.ApprovalTypeCode == ConfigurationManager.AppSettings["purchasingApprover"] || approverObj.ApprovalTypeCode == ConfigurationManager.AppSettings["accountingApprover"]) { response.Add("success", false); response.Add("error", true); response.Add("message", " Primary approvers cannot be de-activated."); } else { approver_model.inactiveApprover(approverObj); response.Add("success", true); response.Add("error", false); response.Add("message", "Record deactivation successfully!"); } } catch (Exception e) { response.Add("success", false); response.Add("error", true); response.Add("message", e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }
}//End /// <summary> /// desc: update the item quantity by partial return /// by: [email protected] /// date: january 16, 2017 /// </summary> /// <returns></returns> /// /// <summary> /// desc: adding of headercode/gate pass number parameter to display on email notification /// by: [email protected] /// date: june 5, 2017 /// version : 2.0 /// </summary> /// <returns></returns> #region PartialReturnQuantity public JsonResult PartialReturnQuantity() { try { var res = new Dictionary <string, object>(); string[] itemCodeArr = Request["ItemCode"].ToString().Split(separator: new char[] { ',' }); string[] itemQuantityArr = Request["PartialQuantity"].ToString().Split(separator: new char[] { ',' }); string[] itemGuidArr = Request["ItemGUID_Arr"].ToString().Split(separator: new char[] { ',' }); for (int i = 0; i < itemCodeArr.Length; i++) { string itemCode = itemCodeArr[i]; string itemQuantity = itemQuantityArr[i]; string itemGuid = itemGuidArr[i]; itemReturnLogsDetails.HeaderCode = Request["HeaderCode"].ToString(); itemReturnLogsDetails.ItemCode = itemCode.ToString(); itemReturnLogsDetails.Quantity = Convert.ToInt32(itemQuantity); itemReturnLogsDetails.IsActive = true; itemReturnLogsDetails.AddedBy = Convert.ToInt32(Session["userId_local"]); itemReturnLogsDetails.DateAdded = DateTime.Now; itemReturnLogsDetails.Remarks = Request["PartialReturnComment"].ToString(); itemReturnLogsDetails.GUID = itemGuid.ToString(); guardModel.PartialReturn_Qty(itemReturnLogsDetails); } ViewBag.headercodeOwnerId = guardModel.GetOwnerofHeader(itemReturnLogsDetails.HeaderCode); ViewBag.departmentcodeapprover = guardModel.GetDepartmentCodebaseOnHeader(itemReturnLogsDetails.HeaderCode); string[] headercodeOwnerEmail = { guardModel.GetOwnerofHeaderEmail(ViewBag.headercodeOwnerId), ConfigurationManager.AppSettings["ampiguard_email"] }; string[] accountingEmail = { guardModel.GetAccountingEmailReturnSlip(itemReturnLogsDetails.HeaderCode), guardModel.GetDepartmentEmailReturnSlip(ViewBag.departmentcodeapprover) }; int getHeaderCodeId = guardModel.getHeaderCodeId(Request["HeaderCode"].ToString()); // used for audit trail purpose auditObj.ProjectCode = "GAT"; // jira story name auditObj.Module = "GUARD"; // module name transacted auditObj.Operation = "Return"; // action inside the module auditObj.Object = "tblTransactionHeaders"; // table name transacted auditObj.ObjectId = getHeaderCodeId; auditObj.ObjectCode = Request["HeaderCode"].ToString(); auditObj.UserCode = Convert.ToInt32(Session["userId_local"]); auditObj.IP = CustomHelper.GetLocalIPAddress(); auditObj.MAC = CustomHelper.GetMACAddress(); auditObj.DateAdded = DateTime.Now; auditModels.AddAuditTrail(auditObj); var emailMod = new EmailModels(); string emailContent = EmailContentReturnSlip(itemReturnLogsDetails.HeaderCode, itemReturnLogsDetails.Remarks); if (!SendEmailReturnSlipByGuard(emailContent, headercodeOwnerEmail, accountingEmail, itemReturnLogsDetails.HeaderCode)) { throw new Exception(message: "Email not sent."); } response.Add(key: "success", value: true); response.Add(key: "error", value: false); response.Add(key: "message", value: " "); } catch (Exception e) { response.Add(key: "success", value: false); response.Add(key: "error", value: true); response.Add(key: "message", value: e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }// End
/// <summary> /// author : [email protected] /// description : for approver update /// version : 1.0 /// <returns>JSON string "Good"</returns> /// UPDATEAPRROVER @ver 1.0 @author rherejias 1/4/2017 /// UPDATEAPRROVER @ver 2.0 @author rherejias 1/16/2017 *added audit trail function /// </summary> public JsonResult editApprover() { try { string userDept = ""; string guardDept = approver_model.getGuardDept(Request["userCode"].ToString()); if (guardDept == ConfigurationManager.AppSettings["GuardDept"]) { response.Add("success", false); response.Add("error", true); response.Add("message", " Guards can't be assigned as approvers."); } else { if (Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryITApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryPurchasingApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryAccountingApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["itApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["purchasingApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["accountingApprover"]) { string test = approver_model.getUserDepartmentName(Request["userCode"].ToString()); userDept = approver_model.getDepartmentCode(test).ToString(); } else { userDept = Request["departmentCode"].ToString(); } string ApprovalTypeCode = Request["approvalTypeCode"].ToString(); approverObj.Id = Convert.ToInt32(Request["id"]); approverObj.Code = Request["code"].ToString(); approverObj.DepartmentCode = userDept; approverObj.UserCode = Request["userCode"].ToString(); approverObj.AddedBy = Convert.ToInt32(Session["userId_local"]); approverObj.IP = CustomHelper.GetLocalIPAddress(); approverObj.MAC = CustomHelper.GetMACAddress(); approverObj.DateAdded = DateTime.Now; bool IsApproverExist = approver_model.IsApproverExistAndDept(approverObj.UserCode, userDept, ApprovalTypeCode); long isExist = approver_model.isUsernameExistEdit(approverObj.UserCode, ApprovalTypeCode); long isPrimaryExist = approver_model.isPrimaryExist(approverObj.DepartmentCode); if (IsApproverExist == true) { approver_model.editApprover(approverObj); response.Add("success", true); response.Add("error", false); response.Add("message", "Record updated successfully!"); } else { //if (isExist.ToString() == approverObj.Code) //{ // approver_model.editApprover(approverObj); // response.Add("success", true); // response.Add("error", false); // response.Add("message", "Record updated successfully!"); //} //else //{ response.Add("success", false); response.Add("error", true); response.Add("message", " User already exist."); //} } } } catch (Exception e) { response.Add("success", false); response.Add("error", true); response.Add("message", e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }
/// <summary> /// author : [email protected] /// description : for approver addtion /// <returns>JSON string "Good"</returns> /// ADDAPPROVER @ver 1.0 @author rherejias 1/4/2017 /// ADDAPPROVER @ver 2.0 @author rherejias 1/16/2017 *added audit trail function /// </summary> public JsonResult addApprover() { try { string IsGuard = approver_model.getUserDepartmentName(Request["userCode"].ToString()); if (IsGuard == ConfigurationManager.AppSettings["GuardDept"]) { response.Add("success", false); response.Add("error", true); response.Add("message", " Guards can't be assigned as approvers."); } else { string userDept = ""; if (Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryITApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryPurchasingApprover"] || Request["approvalTypeCode"].ToString() == ConfigurationManager.AppSettings["secondaryAccountingApprover"]) { string dept = approver_model.getUserDepartmentName(Request["userCode"].ToString()); userDept = approver_model.getDepartmentCode(dept).ToString(); } else { userDept = Request["departmentCode"].ToString(); } approverObj.ApprovalTypeCode = Request["approvalTypeCode"].ToString(); approverObj.DepartmentCode = userDept; approverObj.UserCode = Request["userCode"].ToString(); approverObj.DateAdded = DateTime.Now; approverObj.AddedBy = Convert.ToInt32(Session["userId_local"]); approverObj.IsActive = true; approverObj.IP = CustomHelper.GetLocalIPAddress(); approverObj.MAC = CustomHelper.GetMACAddress(); bool IsExist = approver_model.IsApproverExistAndDept(approverObj.UserCode, approverObj.DepartmentCode, approverObj.ApprovalTypeCode); if (IsExist == true) { approver_model.addApprover(approverObj); response.Add("success", true); response.Add("error", false); response.Add("message", "Record added successfully!"); } else { response.Add("success", false); response.Add("error", true); response.Add("message", " User already exist."); } } } catch (Exception e) { response.Add("success", false); response.Add("error", true); response.Add("message", e.ToString()); } return(Json(response, JsonRequestBehavior.AllowGet)); }