public static sysGlobalClass.CResutlWebMethod DeleteData(string[] arrValue) { sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod(); if (!UserAcc.UserExpired()) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <int> lstDelID = new List <int>(); if (arrValue != null) { lstDelID = arrValue.Select(s => s.toIntNullToZero()).ToList(); } int nUserID = UserAcc.GetObjUser().nUserID; db.mTCompany.Where(w => w.ID != EPIFunc.DataType.Company.PTTGCID && lstDelID.Contains(w.ID)).ToList().ForEach(x => { x.cDel = "Y"; x.dUpdate = DateTime.Now; x.UpdateID = nUserID; }); db.mTFacility.Where(w => lstDelID.Contains(w.CompanyID)).ToList().ForEach(x => { x.cDel = "Y"; x.dUpdate = DateTime.Now; x.UpdateID = nUserID; }); db.SaveChanges(); result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_SessionExpired; } return(result); }
public static List <TDataSAPFacility> SearchSAPFacility(string sSearch, string sFacilityID, string sAssesstID) { List <TDataSAPFacility> lstData = new List <TDataSAPFacility>(); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); int nFacID = STCrypt.Decrypt(sFacilityID).toIntNullToZero(); var dataFac = db.mTFacility.FirstOrDefault(w => w.ID == nFacID); if (dataFac != null) { var dataCompany = db.mTCompany.FirstOrDefault(w => w.ID == dataFac.CompanyID); if (dataCompany != null) { int?nAssessetID = null; if (!string.IsNullOrEmpty(sAssesstID)) { nAssessetID = STCrypt.Decrypt(sAssesstID).toIntNull(); } var qFacSAPCode = db.mTFacility.Where(w => w.cDel == "N" && w.nLevel == 2 && !string.IsNullOrEmpty(w.sRefFacCode) && (nAssessetID.HasValue ? w.ID != nAssessetID : true)).Select(s => s.sRefFacCode).ToList(); sSearch = sSearch.Trims().ToLower(); var dataVPlant = db.v_TM_SAP_ALLFAC.Where(w => w.sType == "P" && !qFacSAPCode.Contains(w.sCode) && w.sCompCode == dataCompany.sCode && ((w.sName + "").ToLower().Contains(sSearch) || (w.sShortName + "").ToLower().Contains(sSearch) || (w.sCode + "").ToLower().Contains(sSearch))).Select(s => new TDataSAPFacility { sCode = s.sCode, sName = s.sCode + " - " + s.sName }).OrderBy(o => o.sName).Take(30).ToList(); var dataVComp = db.v_TM_SAP_ALLFAC.Where(w => w.sType == "O" && !qFacSAPCode.Contains(w.sCode) && ((w.sName + "").ToLower().Contains(sSearch) || (w.sShortName + "").ToLower().Contains(sSearch) || (w.sCode + "").ToLower().Contains(sSearch))).Select(s => new TDataSAPFacility { sCode = s.sCode, sName = s.sCode + " - " + s.sName }).OrderBy(o => o.sName).Take(30).ToList(); lstData = dataVPlant.Concat(dataVComp).OrderBy(o => o.sName).Take(30).ToList(); } } return(lstData); }
public static ResultData LoadData(TSearch item) { ResultData r = new ResultData(); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <ClassExecute.TDataOutput> lstDataT1 = new List <ClassExecute.TDataOutput>(); List <ClassExecute.TDataOutput> lstData = new List <ClassExecute.TDataOutput>(); int nFormID = 0; var qForm = db.TEPI_Forms.FirstOrDefault(w => w.IDIndicator == item.nIndicator && w.OperationTypeID == item.nOperationType && w.FacilityID == item.nFacility && w.sYear == item.sYear); if (qForm != null) { nFormID = qForm.FormID; } if (item.nIndicator == 10) { lstData = FunctionGetData.GetWasteDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 8) { lstData = FunctionGetData.GetMaterialDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 6) { lstData = FunctionGetData.GetIntensityDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 11) { lstData = FunctionGetData.GetWaterDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 1) { lstData = FunctionGetData.GetComplaintDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 2) { lstData = FunctionGetData.GetComplianceDataOutput(nFormID, item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 3) { lstData = FunctionGetData.GetDataOutput(item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } else if (item.nIndicator == 4) { lstData = FunctionGetData.GetDataOutput(item.nIndicator, item.nOperationType, item.nFacility, item.sYear); lstDataOutputEmission(item.nIndicator, item.nOperationType, item.nFacility, item.sYear, r); } else if (item.nIndicator == 9) { lstData = FunctionGetData.GetDataOutput(item.nIndicator, item.nOperationType, item.nFacility, item.sYear); } r.lstData = lstData; r.sFormID = nFormID + ""; r.Status = SystemFunction.process_Success; return(r); }
public static List <TDataRole> GetRolePermission(string sUserID) { List <TDataRole> lstData = new List <TDataRole>(); DataTable dt = new DataTable(); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); int nUserID = 0; if (!string.IsNullOrEmpty(sUserID)) { nUserID = int.Parse(sUserID); } var TBUser_InRow = db.mTUserInRole.Where(w => w.nUID == nUserID).ToList(); var lstDataRole = db.mTUserRole.ToList(); if (TBUser_InRow.Any()) { TBUser_InRow.ForEach(f => { lstData.Add(new TDataRole { nRoleID = f.nRoleID, sRoleName = lstDataRole.Any(a => a.ID == f.nRoleID) ? lstDataRole.First(a => a.ID == f.nRoleID).Name : "", }); }); } lstData = lstData.Distinct().ToList(); return(lstData); }
public void setCBL() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstComplaintType = db.TM_ComplaintType.Where(w => w.cDel != "Y").Select(s => new { nType = s.nType, Value = s.nID + "", Text = s.sName }).ToList(); ddlComplaintType.DataSource = lstComplaintType.Where(w => w.nType == 1).ToList(); ddlComplaintType.DataValueField = "Value"; ddlComplaintType.DataTextField = "Text"; ddlComplaintType.DataBind(); ddlComplaintType.Items.Insert(0, new ListItem("- Please select complaint type -", "")); cblImpactType.DataSource = lstComplaintType.Where(w => w.nType == 2).ToList(); cblImpactType.DataValueField = "Value"; cblImpactType.DataTextField = "Text"; cblImpactType.DataBind(); ddlComplaintBy.DataSource = lstComplaintType.Where(w => w.nType == 3).ToList(); ddlComplaintBy.DataValueField = "Value"; ddlComplaintBy.DataTextField = "Text"; ddlComplaintBy.DataBind(); ddlComplaintBy.Items.Insert(0, new ListItem("- Please select complaint by -", "")); }
public void setData(int nFacilityID) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var dataFacility = db.mTFacility.FirstOrDefault(w => w.ID == nFacilityID); if (dataFacility != null) { txtFacilityName.Text = dataFacility.Name; ddlOperationType.SelectedValue = dataFacility.OperationTypeID + ""; txtDesc.Text = dataFacility.Description; txtRemark.Text = dataFacility.sRemark; rblStatus.SelectedValue = dataFacility.cActive; txtMapPTTCode.Text = dataFacility.sMappingCodePTT; if (rblStatus.SelectedValue == "N") { txtRemark.Enabled = true; } if (hdfComType.Value == "GC") { ddlFacilityPTT.SelectedValue = dataFacility.nHeaderID + ""; var lstOperationTypeGC = db.mOperationType.Where(w => w.cDel == "N" && w.cManage == "Y").ToList(); //db.mTFacility_Operationtype.Where(w => w.nFacID == nFacilityID).ToList().ForEach(f => //{ // if (lstOperationTypeGC.Any(a => a.ID == f.nOperationtypeID)) // { // cblOperationTypeGC.Items.FindByValue(f.nOperationtypeID + "").Selected = true; // } //}); } } }
public static sysGlobalClass.CResutlWebMethod getOperationTypePTT(string sFacilityPTT_ID) { sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod(); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); if (!UserAcc.UserExpired()) { int nFacilityPTT_ID = SystemFunction.GetIntNullToZero(sFacilityPTT_ID); var item = db.mTFacility.FirstOrDefault(w => w.ID == nFacilityPTT_ID); if (item != null) { result.Content = item.OperationTypeID + ""; result.Status = SystemFunction.process_Success; } else { result.Msg = "Data operation type not found."; result.Status = SystemFunction.process_Failed; } } else { result.Status = SystemFunction.process_SessionExpired; } return(result); }
private void DDL_OperationType(int nRoleID, int nUserID) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstOperationType_Search = db.mOperationType.Where(w => w.cDel == "N" && w.cActive == "Y" && w.cManage == "N").Select(s => new { Value = s.ID, Text = s.Name }).ToList(); //if (nRoleID == 6) //{ // var db1 = (from a in db.mTUser_FacilityPermission select a).ToList(); // var db2 = (from a in db.mTFacility select a).ToList(); // var db3 = (from a in db.mOperationType select a).ToList(); // //var lstOperationType_1 = db.mOperationType.Where(w => w.cDel == "N" && w.cActive == "Y" && w.cManage == "N").Select(s => new { Value = s.ID, Text = s.Name }).ToList(); // lstOperationType_Search = (from a in db1 // join b in db2 on a.nFacilityID equals b.ID // join c in db3 on b.OperationTypeID equals c.ID // where a.nUserID == nUserID // select new { Value = c.ID, Text = c.Name }).Distinct().ToList(); //} if (lstOperationType_Search.Count() > 0) { ddlOperationSearch.DataSource = lstOperationType_Search; ddlOperationSearch.DataValueField = "Value"; ddlOperationSearch.DataTextField = "Text"; ddlOperationSearch.DataBind(); ddlOperationSearch.Items.Insert(0, new ListItem("- Operation type -", "")); } }
protected void Page_Load(object sender, EventArgs e) { if (UserAcc.UserExpired()) { SetBodyEventOnLoad(SystemFunction.PopupLogin()); } else { if (!IsPostBack) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); string str = Request.QueryString["strid"]; if (!string.IsNullOrEmpty(str)) { int nFacID = SystemFunction.GetIntNullToZero(STCrypt.Decrypt(str)); hdfFacID.Value = str; ltrCreate.Text = "<a class=\"btn btn-primary btn-sm btn-block\" href=\"admin_asset_update.aspx?strid=" + HttpUtility.UrlEncode(str) + "\"><i class=\"fa fa-plus\"></i> Create Sub-facility</a>"; var itemHeader = db.mTFacility.FirstOrDefault(w => w.ID == nFacID); if (itemHeader != null) { var itemCompany = db.mTCompany.FirstOrDefault(w => w.ID == itemHeader.CompanyID); ltrHeader.Text = "<a href='admin_company_lst.aspx' style='color:white'>Organization</a> > <a style='color:white' href='admin_facility_lst.aspx?strid=" + HttpUtility.UrlEncode(STCrypt.Encrypt(itemCompany.ID + "")) + "'> " + itemCompany.Name + "</a> > " + itemHeader.Name;//กำหนด Header } } SystemFunction.BindDropdownPageSize(ddlPageSize, null); } } }
public static TRetunrLoadData Get_Facility(string operationID) { //if (lst == null) lst = new List<string>(); TRetunrLoadData result = new TRetunrLoadData(); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); if (UserAcc.UserExpired()) { result.Status = SystemFunction.process_SessionExpired; } else { int nRoleID = UserAcc.GetObjUser().nRoleID; int nUserID = UserAcc.GetObjUser().nUserID; List <sysGlobalClass.T_Facility> lstFacility = new List <sysGlobalClass.T_Facility>(); if (!string.IsNullOrEmpty(operationID)) { int nID = int.Parse(operationID); lstFacility = SystemFunction.Get_SubFacility(nID, nUserID, nRoleID); } result.lstData_Facility = lstFacility.Distinct().ToList(); } return(result); }
private void DDL_Role_Environ() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <DropDownList> lstDropDown = new List <DropDownList>(); //var lstEnviron = db.mTUser_FacilityPermission.Where(w => w.nRoleID == 4).Select(s => new { nUserID = s.nUserID }).Distinct().ToList(); var lstEnviron = db.mTUserInRole.Where(w => w.nRoleID == 4).Select(s => new { nUserID = s.nUID }).Distinct().ToList(); if (lstEnviron.Any()) { lstEnviron.ForEach(f => { db.mTUser.Where(w => w.cDel == "N" && w.cActive == "Y" && w.ID == f.nUserID).ToList().ForEach(f2 => { lstDropDown.Add(new DropDownList() { Value = f2.ID, Text = f2.Firstname + ' ' + f2.Lastname, }); }); if (lstDropDown.Any()) { ddlEnviron.DataSource = lstDropDown; ddlEnviron.DataValueField = "Value"; ddlEnviron.DataTextField = "Text"; ddlEnviron.DataBind(); } }); } ddlEnviron.Items.Insert(0, new ListItem("- Environment -", "")); }
public static CResultHistory ViewHistory(int nFacID, int nYear, int nIndID, int nQuarter) { CResultHistory result = new CResultHistory(); if (!UserAcc.UserExpired()) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <TDataHistory> lstData = new List <TDataHistory>(); lstData = (from d in db.TEPI_TransferPTT_Log.Where(w => w.nFacilityID == nFacID && w.nYear == nYear && w.nIndicatorID == nIndID && w.nQuarter == nQuarter) from u in db.mTUser.Where(w => w.ID == d.nActionBy).DefaultIfEmpty() from st in db.TStatus_Workflow.Where(w => w.nStatustID == d.nStatusID && w.cActive == "Y" && w.cTypeUse == "TNF").DefaultIfEmpty() orderby d.dAction descending select new TDataHistory { dAction = d.dAction, sStatus = st != null ? st.sStatusName : "-", sActionBy = u != null ? u.Firstname + " " + u.Lastname : d.nActionBy == -1 ? "PTT" : "", sComment = d.sRemark }).ToList(); foreach (var item in lstData) { item.sDate = item.dAction.DateString(); item.sComment = (item.sComment + "").Replace("\n", "<br/>"); } result.lstData = lstData; result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_SessionExpired; } return(result); }
public static sysGlobalClass.CResutlWebMethod ApproveWithEditContent(int FormID) { PTTGC_EPIEntities env = new PTTGC_EPIEntities(); sysGlobalClass.CResutlWebMethod r = new sysGlobalClass.CResutlWebMethod(); int nOperationType = 0; if (!UserAcc.UserExpired()) { var gData = env.TEPI_Forms.FirstOrDefault(f => f.FormID == FormID); if (gData != null) { r.Msg = SystemFunction.ReturnPath(gData.IDIndicator, gData.OperationTypeID, gData.FacilityID.ToString(), gData.sYear, "27"); r.Status = SystemFunction.process_Success; } else { r.Msg = ""; r.Status = SystemFunction.process_Failed; } } else { r.Msg = ""; r.Status = SystemFunction.process_SessionExpired; } return(r); }
private void SETDATA(string sID) { if (!string.IsNullOrEmpty(sID)) { int nID = SystemFunction.GetIntNullToZero(sID); PTTGC_EPIEntities db = new PTTGC_EPIEntities(); DateTime now = DateTime.Now; var Query = db.TContactUs.FirstOrDefault(w => w.cDel == "N" && w.nContactID == nID); if (Query != null) { if (Query.cStatusAns == null) { Query.cStatusAns = "1"; Query.dUpdate = now; db.SaveChanges(); } if (Query.cStatusAns == "2") { txtDesc.Text = Query.sAnswer; txtDesc.Attributes.Add("disabled", "true"); DivFileContactUS.Visible = false; // lbUrlFileAdmin.Text = Query.sAnsPath + Query.sAnsFile; if (!string.IsNullOrEmpty(Query.sAnsFile)) { lbUrlFileAdmin.Text = "<a class='btn btn-primary'href=" + Query.sAnsPath + Query.sAnsSysFile + " target='_blank'><i class='fa fa-search'></i> " + Query.sAnsFile + "</a>"; } else { lbUrlFileAdmin.Text = "-"; } } else { DivShowFileAdmin.Visible = false; } hidsStatus.Value = Query.cStatusAns; lbName.Text = Query.sContactName; lbEmail.Text = Query.sContactEmail; lbSubject.Text = Query.sSubject; lbTel.Text = Query.sContactTel; lbUserDes.Text = Query.sDetail; lbAddDate.Text = Query.dCreate.ToString(); //lbUrlFileUser.Text = Query.sContactPath + Query.sContactFile; if (!string.IsNullOrEmpty(Query.sContactFile)) { lbUrlFileUser.Text = "<a class='btn btn-primary'href=" + Query.sContactPath + Query.sContactSysFile + " target='_blank'><i class='fa fa-search'></i> " + Query.sContactFile + "</a>"; } else { lbUrlFileUser.Text = "-"; } lbStatus.Text = Query.cStatusAns == null ? "Wait" : Query.cStatusAns == "1" ? "Read" : "Success"; } } }
public static List <ClassExecute.TData_Intensity_DisplayInput> GetDataDisplayInputIntensity() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <ClassExecute.TData_Intensity_DisplayInput> lstTemp = new List <ClassExecute.TData_Intensity_DisplayInput>(); lstTemp = db.TIntensity_DisplayInput.Select(s => new ClassExecute.TData_Intensity_DisplayInput { ID = s.ID, OperaID = s.OperationTypeID.Value, nDisplayType = s.DisplayType.Value, sUrl = s.sUrl }).ToList(); return(lstTemp); }
public void setData(int nFacID, int?nAssetID) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var dataAsset = db.mTFacility.FirstOrDefault(w => w.ID == nAssetID); var dataFacility = db.mTFacility.FirstOrDefault(w => w.ID == nFacID); if (dataFacility != null) { txtFacilityName.Text = dataFacility.Name; //db.mTFacility_Operationtype.Where(w => w.nFacID == dataFacility.ID).ToList().ForEach(f => //{ // ListItem itemFac = cblOperationTypeGC.Items.FindByValue(f.nOperationtypeID + ""); // if (itemFac != null) // { // cblOperationTypeGC.Items.FindByValue(f.nOperationtypeID + "").Selected = true; // } //}); } if (dataAsset != null) { rblOption.SelectedValue = dataAsset.sRefFacType == "" ? "N" : dataAsset.sRefFacType; if (rblOption.SelectedValue == "P")//SAP Master (Plant) { txtSAPFacilitySearch.Text = dataAsset.sRefFacCode + " - " + dataAsset.Name; txtSAPFacilityCode.Text = dataAsset.sRefFacCode; } else//Manual (None) { ddlCategory.SelectedValue = dataAsset.sRefFacSubType + ""; txtSubFacManual.Text = dataAsset.Name; if (!string.IsNullOrEmpty(dataAsset.sRefFacCode)) { txtRefSAPCodeSearch.Text = dataAsset.sRefFacCode + " - " + dataAsset.Name; txtRefSAPCodeValue.Text = dataAsset.sRefFacCode; } txtInternalCode.Text = dataAsset.sInternalCode + ""; if (!string.IsNullOrEmpty(dataAsset.sRefFacSubType)) { ddlCategory.Enabled = false; } } txtDesc.Text = dataAsset.Description; txtRemark.Text = dataAsset.sRemark; //txtCodeSap.Text = dataAsset.sRefFacCode; //txtNameSap.Text = dataAsset.sSAPName; rblStatus.SelectedValue = dataAsset.cActive; if (rblStatus.SelectedValue == "N") { txtRemark.Enabled = true; } } }
public static Data_Month GetMonth(int FormID, int nLevel) { Data_Month r = new Data_Month(); r.lstShowButton = new List <string>(); PTTGC_EPIEntities env = new PTTGC_EPIEntities(); var gMonth = env.TEPI_Workflow.Where(w => w.FormID == FormID).ToList(); if (!UserAcc.UserExpired()) { int[] lstStatusL1 = { 1 }; int[] lstStatusL2 = { 4, 2 }; if (gMonth.Any()) { if (nLevel == 3) { r.lstMonth = gMonth.Where(w => lstStatusL1.Contains(w.nStatusID ?? 0)).Select(s => s.nMonth).ToList(); if (r.lstMonth.Any()) { r.lstShowButton.Add("btnAppr"); r.lstShowButton.Add("btnReject"); } }// L1 else if (nLevel == 4) { r.lstMonth = gMonth.Where(w => lstStatusL2.Contains(w.nStatusID ?? 0)).Select(s => s.nMonth).ToList(); if (r.lstMonth.Any()) { r.lstShowButton.Add("btnAppr"); r.lstShowButton.Add("btnReject"); } if (gMonth.Any(w => w.nStatusID == 2)) { r.lstShowButton.Add("btnAppr_with"); r.lstShowButton.Add("btnAppr_Re"); } }//L2 r.Msg = ""; r.Status = SystemFunction.process_Success; } else { r.Msg = "No Data"; r.Status = SystemFunction.process_Failed; } } else { r.Msg = ""; r.Status = SystemFunction.process_SessionExpired; } return(r); }
public static sysGlobalClass.CResutlWebMethod ForgetPassword(string sEmail, string sUsername) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod(); sEmail = sEmail.ToLower(); sUsername = sUsername.ToLower(); var lstUser = db.mTUser.Where(w => w.cActive == "Y" && w.cDel == "N" && w.Username.ToLower() == sUsername && w.Email.ToLower() == sEmail).ToList(); if (lstUser.Any()) { var Data = lstUser.First(); string sTitle = ""; string sText = ""; string subject = ""; string message = ""; string sURL = ""; string sFoot = "";// "Should you have any questions about RD&T work process."; // sURL = Applicationpath + "login_forget.aspx?str=" + SystemFunction.Encrypt_UrlEncrypt(nDocID + ""); subject = "Password Confirmation | " + SystemFunction.SystemName + ""; sText += "<p>Your password is " + STCrypt.Decrypt(Data.PasswordEncrypt) + "</p>"; string From = SystemFunction.GetSystemMail; string To = Data.Email; message = string.Format(GET_TemplateEmail(), "Dear " + Data.Firstname + ' ' + Data.Lastname, sText, sURL, sFoot, "", ""); Workflow.DataMail_log log = new Workflow.DataMail_log(); log = SystemFunction.SendMailAll(From, To, "", "", subject, message, ""); log.nDataID = SystemFunction.GetIntNullToZero(Data.ID + ""); log.sPageName = "login.aspx"; new Workflow().SaveLogMail(log); if (log.bStatus) { result.Status = SystemFunction.process_Success; } } else { result.Status = SystemFunction.process_Failed; result.Msg = "data not found user"; } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!UserAcc.UserExpired()) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); string str = Request.QueryString["strid"]; string strFacID = Request.QueryString["strFacID"]; int nFacilityID = 0; bool IsNew = false; if (!string.IsNullOrEmpty(str)) { hdfReturnStr.Value += "&&strid=" + HttpUtility.UrlEncode(str); int nComID = SystemFunction.GetIntNullToZero(STCrypt.Decrypt(str)); hdfComType.Value = nComID == 1 ? "PTT" : "GC"; hdfComID.Value = str; var itemCompany = db.mTCompany.FirstOrDefault(w => w.ID == nComID && w.cDel == "N"); if (itemCompany != null) { if (!string.IsNullOrEmpty(strFacID)) { IsNew = false; nFacilityID = SystemFunction.GetIntNullToZero(STCrypt.Decrypt(strFacID)); hdfFacilityID.Value = strFacID; var itemFacility = db.mTFacility.FirstOrDefault(w => w.cDel == "N" && w.ID == nFacilityID); if (itemFacility != null) { ltrHeader.Text = "<a href='admin_company_lst.aspx' style='color:white'>Organization</a> > <a href='admin_facility_lst.aspx?strid=" + HttpUtility.UrlEncode(str) + "' style='color:white'>" + itemCompany.Name + "</a> > " + itemFacility.Name + " > Edit";//กำหนด Header กรณีเข้ามา EDIT } } else { IsNew = true; ltrHeader.Text = "<a href='admin_company_lst.aspx' style='color:white'>Organization</a> > <a href='admin_facility_lst.aspx?strid=" + HttpUtility.UrlEncode(str) + "' style='color:white'>" + itemCompany.Name + "</a> > Facility > Create";//กำหนด Header กรณีเข้ามา ADD } hdfIsNew.Value = IsNew ? "C" : "E"; } setDDL_Cbl(IsNew, nComID); setData(nFacilityID); } if (string.IsNullOrEmpty(str) && string.IsNullOrEmpty(strFacID)) { SetBodyEventOnLoad(SystemFunction.DialogWarningRedirect(SystemFunction.Msg_HeadWarning, "Invalid Data", "admin_company_lst.aspx"));// กรณีเข้ามาด้วย link ที่ไม่มี Querystring } } else { SetBodyEventOnLoad(SystemFunction.PopupLogin()); } } }
private void DDL_Role() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstUserRole = db.mTUserRole.Where(w => w.cDel == "N" && w.cActive == "Y").Select(s => new { Value = s.ID, Text = s.Name }).ToList(); if (lstUserRole.Count() > 0) { ddlUserRole.DataSource = lstUserRole; ddlUserRole.DataValueField = "Value"; ddlUserRole.DataTextField = "Text"; ddlUserRole.DataBind(); ddlUserRole.Items.Insert(0, new ListItem("- User role -", "")); } }
private void DDL_Facility() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstFacility = db.mTFacility.Where(w => w.nLevel == 2 && w.cDel == "N" && w.cActive == "Y").Select(s => new { Value = s.ID, Text = s.Name }).ToList(); if (lstFacility.Count() > 0) { ddlFacilitySearch.DataSource = lstFacility; ddlFacilitySearch.DataValueField = "Value"; ddlFacilitySearch.DataTextField = "Text"; ddlFacilitySearch.DataBind(); ddlFacilitySearch.Items.Insert(0, new ListItem("- Sub facility -", "")); } }
private void DDL_Disposal() { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstData = db.TData_Type.Where(w => w.cActive == "Y" && w.sType == "DISCODE").Select(s => new { Value = s.nID, Text = s.sName }).ToList(); if (lstData.Count() > 0) { ddlDisposal.DataSource = lstData; ddlDisposal.DataValueField = "Value"; ddlDisposal.DataTextField = "Text"; ddlDisposal.DataBind(); ddlDisposal.Items.Insert(0, new ListItem("- Disposal Type -", "")); } }
public static TRetunrLoadData ConfirmData(List <TDataDupicate> lstData, List <TDataFacAndIndicator> lstData_Save) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); TRetunrLoadData result = new TRetunrLoadData(); string Del_SQL = ""; string Insert_SQL = ""; DateTime now = DateTime.Now; int nUserID = UserAcc.GetObjUser().nUserID; if (UserAcc.UserExpired()) { result.Status = SystemFunction.process_SessionExpired; } else { if (lstData.Count > 0) { foreach (var item in lstData) { Del_SQL += @" DELETE FROM mTWorkFlow WHERE IDFac = " + item.nFacID + @" AND IDIndicator = " + item.nIndicatorID + @" "; Insert_SQL += @" INSERT INTO mTWorkFlow (IDFac,IDIndicator,L1,L2,nUpdateID,dUpdate,cDel) VALUES ('" + item.nFacID + @"','" + item.nIndicatorID + @"','" + item.sManagerID + @"','" + item.sEnvironID + @"','" + nUserID + @"','" + now + @"','N') "; } SystemFunction.ExecuteSQL(SystemFunction.strConnect, Del_SQL); SystemFunction.ExecuteSQL(SystemFunction.strConnect, Insert_SQL); result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_Failed; result.Msg = "Data not found"; } if (lstData_Save.Count > 0) { foreach (var item in lstData_Save) { Del_SQL += @" DELETE FROM mTWorkFlow WHERE IDFac = " + item.nFacID + @" AND IDIndicator = " + item.nIndicatorID + @" "; Insert_SQL += @" INSERT INTO mTWorkFlow (IDFac,IDIndicator,L1,L2,nUpdateID,dUpdate,cDel) VALUES ('" + item.nFacID + @"','" + item.nIndicatorID + @"','" + item.sManagerID + @"','" + item.sEnvironID + @"','" + nUserID + @"','" + now + @"','N') "; } SystemFunction.ExecuteSQL(SystemFunction.strConnect, Del_SQL); SystemFunction.ExecuteSQL(SystemFunction.strConnect, Insert_SQL); result.Status = SystemFunction.process_Success; } } return(result); }
protected void Page_Load(object sender, EventArgs e) { SetBodyEventOnLoad(""); if (UserAcc.UserExpired()) { SetBodyEventOnLoad(SystemFunction.PopupLogin()); } else { if (!IsPostBack) { PTTGC_EPIEntities env = new PTTGC_EPIEntities(); string sFormID = Request.QueryString["strid"]; // Form ID string sLevel = Request.QueryString["strlevel"]; // Level (L1 = 3,L2 = 4 ,L0 = 2) After Decrypt int nFormID = 0; int.TryParse(STCrypt.Decrypt(sFormID), out nFormID); var gDataForm = env.TEPI_Forms.FirstOrDefault(w => w.FormID == nFormID); if (!string.IsNullOrEmpty(sFormID)) { if (gDataForm != null) { hidFacility.Value = gDataForm.FacilityID.ToString(); hidIndicator.Value = gDataForm.IDIndicator.ToString(); hidOperationType.Value = gDataForm.OperationTypeID.ToString(); hidYear.Value = gDataForm.sYear; var qOpera = env.mOperationType.FirstOrDefault(w => w.ID == gDataForm.OperationTypeID); var qFac = env.mTFacility.FirstOrDefault(w => w.ID == gDataForm.FacilityID); var qGroupInd = env.mTIndicator.FirstOrDefault(w => w.ID == gDataForm.IDIndicator); lblGroupIndicator.Text = qGroupInd != null ? qGroupInd.Indicator : ""; lblOperationtype.Text = qOpera.Name; lblFacility.Text = qFac != null ? qFac.Name : ""; lblYear.Text = gDataForm.sYear; } hidFormID.Value = STCrypt.Decrypt(sFormID); if (!string.IsNullOrEmpty(sLevel)) { hidLevel.Value = STCrypt.Decrypt(sLevel); } } else { Response.Redirect("epi_mytask.aspx"); } } } }
public static CResultLogin Login(string sUserName, string sPassword, string sMode) { CResultLogin result = new CResultLogin(); UserAcc ua = new UserAcc(); if (!string.IsNullOrEmpty(sUserName)) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); sUserName = sUserName.Trims(); sPassword = sPassword.Trims(); var query = db.mTUser.FirstOrDefault(w => w.Username == sUserName && w.cDel == "N" && w.cActive == "Y"); if (query != null) { if (sPassword == ConfigurationManager.AppSettings["DefaultPass"].ToString()) { var qRole = db.mTUserInRole.FirstOrDefault(w => w.nUID == query.ID); if (qRole != null) { var qRoleName = db.mTUserRole.FirstOrDefault(w => w.ID == qRole.nRoleID); ua.nUserID = query.ID; ua.sFullName = query.Firstname + " " + query.Lastname; ua.nRoleID = qRole.nRoleID; ua.sActionRoleName = qRoleName != null ? qRoleName.Name : ""; UserAcc.SetObjUser(ua); result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_Failed; result.Msg = "Not found role !"; } } else { result.Status = SystemFunction.process_Failed; result.Msg = "Incorrect pasword !"; } } else { result.Status = SystemFunction.process_Failed; result.Msg = "Not found user !"; } } return(result); }
public void setDDL_Cbl(bool IsNew, int nComID) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); var lstOperationType = db.mOperationType.Where(w => w.cDel == "N" && w.cManage == "N" && (IsNew ? w.cActive == "Y" : true)).Select(s => new { Value = s.ID, Text = s.Name }).ToList(); var lstOperationTypeGC = db.mOperationType.Where(w => w.cDel == "N" && w.cManage == "Y" && (IsNew ? w.cActive == "Y" : true)).Select(s => new { Value = s.ID, Text = s.Name }).ToList(); var lstFacilityPTT = db.mTFacility.Where(w => w.cDel == "N" && w.CompanyID == 1 && w.nLevel == 0 && (IsNew ? w.cActive == "Y" : true)).Select(s => new { Value = s.ID, Text = s.Name }).ToList(); if (lstOperationType.Count() > 0) { ddlOperationType.DataSource = lstOperationType; ddlOperationType.DataValueField = "Value"; ddlOperationType.DataTextField = "Text"; ddlOperationType.DataBind(); ddlOperationType.Items.Insert(0, new ListItem("- Operation Type -", "")); } else { ddlOperationType.Items.Insert(0, new ListItem("- Operation Type -", "")); } //if (lstOperationTypeGC.Count() > 0) //{ // cblOperationTypeGC.DataSource = lstOperationTypeGC; // cblOperationTypeGC.DataValueField = "Value"; // cblOperationTypeGC.DataTextField = "Text"; // cblOperationTypeGC.DataBind(); // foreach (ListItem item in cblOperationTypeGC.Items) // { // item.Attributes["class"] = "col-md-3 col-sm-4 col-xs-6"; // } //} if (lstFacilityPTT.Count() > 0) { ddlFacilityPTT.DataSource = lstFacilityPTT; ddlFacilityPTT.DataValueField = "Value"; ddlFacilityPTT.DataTextField = "Text"; ddlFacilityPTT.DataBind(); ddlFacilityPTT.Items.Insert(0, new ListItem("- Facility Name -", "")); } else { ddlFacilityPTT.Items.Insert(0, new ListItem("- Facility Name -", "")); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SystemFunction.BindDropdownPageSize(ddlPageSize, null); SystemFunction.BindDropdownPageSize(ddlPageSizeGC, null); if (!UserAcc.UserExpired()) { string str = Request.QueryString["strid"]; if (!string.IsNullOrEmpty(str)) { if (SystemFunction.GetIntNullToZero(STCrypt.Decrypt(str)) != 1) { SetBodyEventOnLoad("$('div[id$=divContentGC]').show();$('div[id$=divContent]').hide()"); } else { SetBodyEventOnLoad("$('div[id$=divContentGC]').hide();$('div[id$=divContent]').show()"); } PTTGC_EPIEntities db = new PTTGC_EPIEntities(); int nComID = SystemFunction.GetIntNullToZero(STCrypt.Decrypt(str)); hdfComID.Value = STCrypt.Encrypt(nComID + ""); var itemCompany = db.mTCompany.FirstOrDefault(w => w.ID == nComID && w.cDel == "N"); if (itemCompany != null) { ltrHeader.Text = "<a href='admin_company_lst.aspx' style='color:white'>Organization</a> > " + itemCompany.Name;//กำหนด Header } ltrCreateGC.Text = "<a class=\"btn btn-primary btn-sm btn-block\" href=\"admin_facility_update.aspx?strid=" + HttpUtility.UrlEncode(STCrypt.Encrypt(nComID + "")) + "\"><i class=\"fa fa-plus\"></i> Create Facility</a>"; ltrCreate.Text = "<a class=\"btn btn-primary btn-sm btn-block\" href=\"admin_facility_update.aspx?strid=" + HttpUtility.UrlEncode(STCrypt.Encrypt(nComID + "")) + "\"><i class=\"fa fa-plus\"></i> Create Facility</a>"; } else { SetBodyEventOnLoad(SystemFunction.DialogWarningRedirect(SystemFunction.Msg_HeadWarning, "Invalid Data", "admin_company_lst.aspx"));// กรณีเข้ามาด้วย link ที่ไม่มี Querystring } } else { SetBodyEventOnLoad(SystemFunction.PopupLogin()); } } }
public static CResultLogin Login(string sUserName, string sPassword, string sMode) { CResultLogin result = new CResultLogin(); UserAcc ua = new UserAcc(); if (!string.IsNullOrEmpty(sUserName)) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); sUserName = sUserName.Trims(); sPassword = sPassword.Trims(); int nUserIDSuperAdmin = SystemFunction.ParseInt(ConfigurationManager.AppSettings["UserIDAdmin"].ToString()); var query = db.mTUser.FirstOrDefault(w => w.Username == sUserName && w.cDel == "N" && w.cActive == "Y"); if (query != null && query.ID == nUserIDSuperAdmin) { if (sPassword == ConfigurationManager.AppSettings["SupperAdminPWD"].ToString()) { ua.nUserID = query.ID; ua.sFullName = query.Firstname + " " + query.Lastname; ua.nRoleID = 1; ua.sActionRoleName = "System Admin"; UserAcc.SetObjUser(ua); result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_Failed; result.Msg = "Incorrect password !"; } } else { var resultLogin = UserAcc.Login(sUserName, sPassword, sMode); result.Msg = resultLogin.Msg; result.nUserID = resultLogin.nUserID; result.Status = resultLogin.Status; result.TDataRole = resultLogin.TDataRole; } } return(result); }
public static sysGlobalClass.CResutlWebMethod ApproveAll(List <DataApproveAll> arrValue) { sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod(); if (!UserAcc.UserExpired()) { PTTGC_EPIEntities env = new PTTGC_EPIEntities(); int nUserID = UserAcc.GetObjUser().nUserID; int nRoleID = UserAcc.GetObjUser().nRoleID; var gForm = arrValue.Select(s => s.nFormID).Distinct().ToList(); int FormID = 0; if (gForm.Any()) { gForm.ForEach(f => { FormID = f; List <int> lstMonth = new List <int>(); arrValue.ForEach(f2 => { if (f == f2.nFormID) { lstMonth.Add(f2.nMonth); } }); if (lstMonth.Any()) { result = new Workflow().WorkFlowAction(FormID, lstMonth, "AP", nUserID, nRoleID, ""); } }); } } else { result.Status = SystemFunction.process_SessionExpired; } return(result); }
public static sysGlobalClass.CResutlWebMethod DeleteDataGC(string[] arrValue) { sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod(); if (!UserAcc.UserExpired()) { PTTGC_EPIEntities db = new PTTGC_EPIEntities(); List <int> lstDelID = new List <int>(); if (arrValue != null) { lstDelID = arrValue.Select(s => s.toIntNullToZero()).ToList(); } int nUserID = UserAcc.GetObjUser().nUserID; db.mTFacility.Where(w => lstDelID.Contains(w.ID)).ToList().ForEach(x => { db.mTFacility_Operationtype.RemoveRange(db.mTFacility_Operationtype.Where(w => w.nFacID == x.ID)); x.cDel = "Y"; x.dUpdate = DateTime.Now; x.UpdateID = nUserID; }); foreach (var item in lstDelID) { var qDelSubFac = db.mTFacility.Where(w => w.nLevel == 2 && w.nHeaderID == item); foreach (var itemS in qDelSubFac) { itemS.cDel = "Y"; itemS.dUpdate = DateTime.Now; itemS.UpdateID = nUserID; } } db.SaveChanges(); result.Status = SystemFunction.process_Success; } else { result.Status = SystemFunction.process_SessionExpired; } return(result); }