public static ASP.Image GetImage(this Texture2D texture, ASP.Rectangle pos) { ASP.Image image = new ASP.Image(pos.w, pos.h); for (int i = 0; i < pos.w; ++i) { for (int j = 0; j < pos.h; ++j) { int px = pos.x + i; int py = pos.y + j; if (px >= 0 && px < texture.width && py >= 0 && py < texture.height) image.setPixel(i, j, texture.GetPixel(px, py)); else image.setPixel(i, j, Color.gray); } } return image; }
// Method to add credit cards details to MemberUserControl private void AddCreditCardsDetails(List<Dictionary<string, object>> creditCardsList, ASP.MemberUserControl memberUserControl) { foreach (Dictionary<string, object> creditCard in creditCardsList) { ASP.CreditCardUserControl creditCardUserControl = (ASP.CreditCardUserControl)LoadControl("~/UserControls/CreditCardUserControl.ascx"); creditCardUserControl.SetCardType(creditCard["CardType"].ToString()); creditCardUserControl.SetCardNumber(creditCard["CardNumber"].ToString()); creditCardUserControl.SetCardHolder(creditCard["CardHolder"].ToString()); creditCardUserControl.SetExpiryDate( creditCard["CardExpireMonth"].ToString() + "/" + creditCard["CardExpireYear"].ToString()); memberUserControl.AddCreditCardDetails(creditCardUserControl); } }
// Method to add addresses details to MemberUserControl private void AddAddressesDetails(List<Dictionary<string, object>> addressesList, ASP.MemberUserControl memberUserControl) { foreach (Dictionary<string, object> address in addressesList) { ASP.AddressUserControl addressUserControl = (ASP.AddressUserControl)LoadControl("~/UserControls/AddressUserControl.ascx"); addressUserControl.SetAlias(address["Alias"].ToString()); addressUserControl.SetFullAddress( address["BuildingName"].ToString() + ", " + address["BuildingFloor"].ToString() + ", " + address["BuildingFlat"].ToString() + ", " + address["BuildingBlock"].ToString() + ", " + address["StreetName"].ToString() + ", " + address["StreetNumber"].ToString() + ", "); addressUserControl.SetDistrict(address["District"].ToString()); memberUserControl.AddAddressDetails(addressUserControl); } }
private void SetSLPNumberClinetScript(ASP.wui_slp_slp_slpnumber_ascx slp_num) { if (slp_num == null) return; TextBox TextBoxCode = ((TextBox)slp_num.FindControl("TextBoxCode")); TextBox TextBoxName = ((TextBox)slp_num.FindControl("TextBoxName")); StringBuilder sb = new StringBuilder(); sb.Append(@" var oldTxt_{THIS.ID} = ''; var EmpStr_{THIS.ID} = ''; function DoSearch_{THIS.ID}() { var TextboxCodeObj = $get('{TEXTBOXCODE.CLIENTID}'); if(oldTxt_{THIS.ID} != TextboxCodeObj.value) { if (event != null) //如果鍵盤輸入 { if (event.keyCode != 13)//不是Enter鍵 { SLP_WUIWebService.NumberName(TextboxCodeObj.value, {DecPreciseValue}, GetNameSuccse_{THIS.ID}, GetNameFail_{THIS.ID} ); } } else //不是鍵盤輸入 { SLP_WUIWebService.NumberName(TextboxCodeObj.value, {DecPreciseValue}, GetNameSuccse_{THIS.ID}, GetNameFail_{THIS.ID} ); } } oldTxt_{THIS.ID} = TextboxCodeObj.value; } function GetNameSuccse_{THIS.ID}(result) { var HiddenFieldObj= $get('{HiddenField.CLIENTID}'); HiddenFieldObj.innerText = result; } function GetNameFail_{THIS.ID}(error) { alert(error.get_message()); } "); //</script> sb.Replace("{THIS.ID}", slp_num.ID); sb.Replace("{TEXTBOXCODE.CLIENTID}", TextBoxCode.ClientID); sb.Replace("{LABELNAME.CLIENTID}", TextBoxName.ClientID); sb.Replace("{HiddenField.CLIENTID}", ((HiddenField)slp_num.FindControl("HiddenField1")).ClientID); //取代小數位的變數 sb.Replace("{DecPreciseValue}", slp_num.DecPrecise.ToString()); TextBoxCode.Attributes.Add("onkeyup", "DoSearch_" + slp_num.ID + "();"); #region 以網頁取得JavaScript string outScript = "\n<!-- \n" + sb.ToString() + "\n //--> \n"; System.Web.UI.ScriptManager.RegisterStartupScript(Page, this.GetType(), "Sript_" + this.ID, outScript, true); #endregion if (!slp_num.ReadOnly) { Image Image1 = ((Image)slp_num.FindControl("Image1")); sb = new StringBuilder(); sb.Append(@"javascript:var calCurrency = new CurrencyPopup(""{DivName}"");calCurrency.showNavigationDropdowns();calCurrency.select({FieldID},{NameID},{HDName},'{btnID}','yyyy/MM/dd'); return false;"); sb.Replace("{FieldID}", TextBoxCode.ClientID); sb.Replace("{NameID}", TextBoxName.ClientID); sb.Replace("{HDName}", ((HiddenField)slp_num.FindControl("HiddenField1")).ClientID); sb.Replace("{btnID}", Image1.ClientID); sb.Replace("{DivName}", ((HtmlGenericControl)slp_num.FindControl("CuDiv")).ClientID); Image1.Attributes.Add("onClick", sb.ToString()); } //檢查整數,小數位數 TextBoxCode.Attributes["onblur"] = "Check_SLPNumberValue('" + TextBoxCode.ClientID + "','" + slp_num.DecPrecise + "','" + slp_num.IntPrecise + "');"; }
private void SetNewSLDATE(ASP.wui_slp_slp_slpdate_ascx SLP_SLPDate_Tmp) { string strSLP_SLPDate_CID = SLP_SLPDate_Tmp.ClientID; string strTextBoxCode_CID = ((TextBox)SLP_SLPDate_Tmp.FindControl("TextBoxCode")).ClientID; string strImage1_CID = ((Image)SLP_SLPDate_Tmp.FindControl("Image1")).ClientID; string strRequiredFieldValidator1_CID = ((RequiredFieldValidator)SLP_SLPDate_Tmp.FindControl("RequiredFieldValidator1")).ClientID; string strCustomValidator1_CID = ((CustomValidator)SLP_SLPDate_Tmp.FindControl("CustomValidator1")).ClientID; string strIsRequiredHidden_CID = ((System.Web.UI.HtmlControls.HtmlInputHidden)SLP_SLPDate_Tmp.FindControl("IsRequiredHidden")).ClientID; SetSLPDateClinetScript(strSLP_SLPDate_CID, strRequiredFieldValidator1_CID, strCustomValidator1_CID, strIsRequiredHidden_CID, strImage1_CID, strTextBoxCode_CID); }
/// <summary> /// Obtiene un ASP en base a un ID /// </summary> /// <param name="id">ID de base de datos del ASP</param> /// <returns>ASP</returns> public ASP getById(int id) { ASP asp = context.ASPs.Where(a => a.Id == id).ToList()[0]; return(asp); }
private string SLP_SCRIPT(ASP.wui_slp_slp_slpdate_ascx SLP_DATE) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(" function " + SLP_DATE.ClientID + "_SLPDateLoad()\n"); sb.Append(" {\n"); sb.Append(" var TextBoxCodeID = '" + ((TextBox)SLP_DATE.FindControl("TextBoxCode")).ClientID + "';\n"); sb.Append(" var CalFormat = '%Y/%m/%d';\n"); sb.Append(" var ImgID = '" + ((Image)SLP_DATE.FindControl("Image1")).ClientID + "';\n"); sb.Append(" var RequiredVaildControl = $get('" + ((RequiredFieldValidator)SLP_DATE.FindControl("RequiredFieldValidator1")).ClientID + "');\n"); sb.Append(" var CustomValidControl = $get('" + ((CustomValidator)SLP_DATE.FindControl("CustomValidator1")).ClientID + "');\n"); sb.Append(" var IsRequiredHiddenControl = $get('" + ((System.Web.UI.HtmlControls.HtmlInputHidden)SLP_DATE.FindControl("IsRequiredHidden")).ClientID + "');\n"); sb.Append(" if ($get('" + ((Image)SLP_DATE.FindControl("Image1")).ClientID + "')!=null)\n"); sb.Append(" {\n"); sb.Append(" if ($get('" + ((TextBox)SLP_DATE.FindControl("TextBoxCode")).ClientID + "').readOnly)\n"); sb.Append(" {\n"); sb.Append(" $get('" + ((Image)SLP_DATE.FindControl("Image1")).ClientID + "').style.display = 'none';\n"); sb.Append(" }\n"); sb.Append(" SLPCalendarCreate(TextBoxCodeID,CalFormat,ImgID,RequiredVaildControl,CustomValidControl,IsRequiredHiddenControl);\n"); sb.Append(" }\n"); sb.Append(" if ($get(TextBoxCodeID) != null)\n"); sb.Append(" {\n"); sb.Append(" $get(TextBoxCodeID).onkeydown = " + SLP_DATE.ClientID + "_Filter;//記錄keydown事件\n"); sb.Append(" }\n"); sb.Append(" }\n"); sb.Append(" function " + SLP_DATE.ClientID + "_Filter()\n"); sb.Append(" {\n"); sb.Append(" if(event.keyCode == 13) //過濾按enter不動作\n"); sb.Append(" {\n"); sb.Append(" event.returnValue = false;\n"); sb.Append(" }\n"); sb.Append(" }\n"); return sb.ToString(); }
public async Task <IActionResult> asgDPM(string poNumber) { try { var ASP = _userHelper.GetUser(User).UserProfile.ASPId; var filter = "\"PO_Number\""; var api = _webset.GetAll().Where(x => x.Name == "apiGet").FirstOrDefault(); //Api prod xl //var urll = "https://api.xl.pdb.e-dpm.com/xlpdbapi/prpo_assignment?where={" + filter + ":" + (char)34+ poNumber + (char)34 + "}"; //api dev isat //var urll = "https://api-dev.isat.pdb.e-dpm.com/isatapi/prpo_assignment?where={" + filter + ":" + (char)34 + poNumber + (char)34 + "}"; //api isat prod var urll = api.Value + filter + ":" + (char)34 + poNumber + (char)34 + "}"; HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(urll); WebReq.Method = "GET"; CredentialCache credentialCache = new CredentialCache(); credentialCache.Add( new Uri(urll), "Basic", new NetworkCredential("userebastapi", "Pm1RQ6edV4IZ") ); WebReq.Credentials = credentialCache; HttpWebResponse WebResp = (HttpWebResponse)await WebReq.GetResponseAsync(); Console.WriteLine(WebResp.StatusCode); //Console.WriteLine(WebResp.Server); string jsonString; using (Stream stream = WebResp.GetResponseStream()) //modified from your code since the using statement disposes the stream automatically when done { StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8); jsonString = reader.ReadToEnd(); } AssignmentDPM items = JsonConvert.DeserializeObject <AssignmentDPM>(jsonString); //List<AssignmentDPM> items = JsonConvert.DeserializeObject<List<AssignmentDPM>>(jsonString); int TOTAL_INSERT = 0; int TOTAL_UPDATE = 0; foreach (var a in items._items) { //Console.WriteLine(a.Assignment_No); ASP aspFind = _asp.GetAll().FirstOrDefault(x => x.OtherInfo == a.Vendor_Code_Actual); Assignment AssignmentFind = Service .GetAll() .FirstOrDefault(x => x.AssignmentId == a.Assignment_No); if (AssignmentFind == null) { Assignment nt = new Assignment { AssignmentId = a.Assignment_No, ProjectName = a.Project, SiteID = a.Site_ID, SiteName = a.Site_Name, AssignmentAcceptedDate = DateTime.Parse(a.ASP_Acceptance_Date), PRNo = a.PR_for_ASP, PRDateCreated = DateTime.Parse(a.PR_For_ASP_Date), PONumber = a.PO_Number, PODate = DateTime.Parse(a.PO_Date), LineItemPO = a.PO_Item, AssignmentReady4Bast = true, ShortTextPO = a.Account_Name, SHID = a.WP_ID, ValueAssignment = a.Total_Service_Price, TOP = a.Payment_Terms, AssignmentCreateBy = a.Requisitioner, AssignmentCreateDate = DateTime.Parse(a.created_on), AspId = aspFind.Id, AssignmentCancel = a.PR_PO_Cancelation, Sow = a.SOW_Type, idDPM = a._id, id_project_doc = a.id_project_doc }; Service.Add(nt); //TempData["Messages"] = "Success add Assignment Id " + assigmentId; Console.WriteLine("Success add Assignment Id " + a.Assignment_No); TOTAL_INSERT++; } else if (AssignmentFind != null) { Assignment nt = Service.GetById(AssignmentFind.Id); nt.ProjectName = a.Project; nt.SiteID = a.Site_ID; nt.SiteName = a.Site_Name; nt.AssignmentAcceptedDate = DateTime.Parse(a.ASP_Acceptance_Date); nt.PRNo = a.PR_for_ASP; nt.PRDateCreated = DateTime.Parse(a.PR_For_ASP_Date); nt.PONumber = a.PO_Number; nt.PODate = DateTime.Parse(a.PO_Date); nt.LineItemPO = a.PO_Item; nt.ShortTextPO = a.Account_Name; nt.SHID = a.WP_ID; nt.ValueAssignment = a.Total_Service_Price; nt.TOP = a.Payment_Terms; nt.AssignmentCreateBy = a.Requisitioner; nt.AssignmentCreateDate = DateTime.Parse(a.created_on); nt.AspId = AssignmentFind.AspId; nt.AssignmentCancel = a.PR_PO_Cancelation; nt.AssignmentReady4Bast = true; nt.Sow = a.SOW_Type; nt.idDPM = a._id; nt.id_project_doc = a.id_project_doc; //nt.OtherInfo = shortextPo; Service.Update(nt); //TempData["Messages"] = "Success update Assignment Id " + assigmentId; Console.WriteLine("Success update Assignment Id " + a.Assignment_No); TOTAL_UPDATE++; } } TempData["Messages"] = "Total Inserted = " + TOTAL_INSERT + " , Total Updated = " + TOTAL_UPDATE; } catch (Exception ex) { Console.WriteLine(ex.ToString()); TempData["Messages"] = ex.ToString(); } return(RedirectToAction("Index")); //var response = JsonConvert.DeserializeObject(jsonString); //Console.WriteLine(items.Count); //################################################################################################## //if (User.IsInRole("ASP Admin")) //{ // response = Service.GetDataTablesResponse<AssignmentDto>(request, Mapper, $"AspId.toString().Equals(\"{ASP.ToString()}\") && AssignmentCancel == (\"{false}\")", Includes); //} //return Ok(response); //return new DataTablesJsonResult(response, true); }
public async Task <IActionResult> Import(IFormFile file) { int TOTAL_INSERT = 0; int TOTAL_UPDATE = 0; var uploads = System.IO.Path.Combine(_env.WebRootPath, "temp"); file = Request.Form.Files[0]; using (var fileStream = new FileStream(System.IO.Path.Combine(uploads, file.FileName), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { await file.CopyToAsync(fileStream); try { using (var Stream = new FileStream(System.IO.Path.Combine(uploads, file.FileName), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { using (ExcelPackage package = new ExcelPackage(Stream)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int rowCount = worksheet.Dimension.Rows; int ColCount = worksheet.Dimension.Columns; for (int row = 2; row <= rowCount; row++) { if (worksheet.Cells[row, 1].Value != null && worksheet.Cells[row, 2].Value != null) { DateTime dt; var assigmentId = worksheet.Cells[row, 1].Value.ToString(); var shId = worksheet.Cells[row, 2].Value.ToString(); var siteId = "-"; if (worksheet.Cells[row, 3].Value != null) { siteId = worksheet.Cells[row, 3].Value.ToString(); } var siteName = "-"; if (worksheet.Cells[row, 4].Value != null) { siteName = worksheet.Cells[row, 4].Value.ToString(); } var assigmentAcceptDate = DateTime.Parse(worksheet.Cells[row, 5].Text); var prNumber = worksheet.Cells[row, 6].Value.ToString(); var prDate = DateTime.Parse(worksheet.Cells[row, 7].Text); var poNumber = worksheet.Cells[row, 8].Value.ToString(); var poDate = DateTime.Parse(worksheet.Cells[row, 9].Text); var poLineItem = worksheet.Cells[row, 10].Value.ToString(); var shortextPo = worksheet.Cells[row, 11].Value.ToString(); var project = worksheet.Cells[row, 12].Value.ToString(); var valueAssigment = Decimal.Parse(worksheet.Cells[row, 13].Value.ToString()); var top = worksheet.Cells[row, 14].Value.ToString(); var assignmentCreateBy = worksheet.Cells[row, 15].Value.ToString(); var assignmentCreateDate = DateTime.Parse(worksheet.Cells[row, 16].Text); var asp = worksheet.Cells[row, 17].Value.ToString(); var assignmentCancel = Boolean.Parse(worksheet.Cells[row, 18].Value.ToString()); var sow = worksheet.Cells[row, 19].Value.ToString(); ASP aspFind = _asp.GetAll().FirstOrDefault(x => _excel.TruncateString(x.Name) == _excel.TruncateString(asp)); Assignment AssignmentFind = Service .GetAll() .FirstOrDefault(x => _excel.TruncateString(x.AssignmentId.ToString()) == _excel.TruncateString(assigmentId)); if (AssignmentFind == null) { Assignment nt = new Assignment { AssignmentId = assigmentId, ProjectName = project, SiteID = siteId, SiteName = siteName, AssignmentAcceptedDate = assigmentAcceptDate, PRNo = prNumber, PRDateCreated = prDate, PONumber = poNumber, PODate = poDate, LineItemPO = poLineItem, AssignmentReady4Bast = true, ShortTextPO = shortextPo, SHID = shId, ValueAssignment = valueAssigment, TOP = top, AssignmentCreateBy = assignmentCreateBy, AssignmentCreateDate = assignmentCreateDate, AspId = aspFind.Id, AssignmentCancel = assignmentCancel, Sow = sow }; Service.Add(nt); //TempData["Messages"] = "Success add Assignment Id " + assigmentId; Console.WriteLine("Success add Assignment Id " + assigmentId); TOTAL_INSERT++; } else if (AssignmentFind != null && assignmentCancel != AssignmentFind.AssignmentCancel) { Assignment nt = Service.GetById(AssignmentFind.Id); nt.ProjectName = project; nt.SiteID = siteId; nt.SiteName = siteName; nt.AssignmentAcceptedDate = assigmentAcceptDate; nt.PRNo = prNumber; nt.PRDateCreated = prDate; nt.PONumber = poNumber; nt.PODate = poDate; nt.LineItemPO = poLineItem; nt.ShortTextPO = shortextPo; nt.SHID = shId; nt.ValueAssignment = valueAssigment; nt.TOP = top; nt.AssignmentCreateBy = assignmentCreateBy; nt.AssignmentCreateDate = assignmentCreateDate; nt.AspId = AssignmentFind.AspId; nt.AssignmentCancel = assignmentCancel; nt.AssignmentReady4Bast = true; nt.Sow = sow; nt.OtherInfo = shortextPo; Service.Update(nt); //TempData["Messages"] = "Success update Assignment Id " + assigmentId; Console.WriteLine("Success update Assignment Id " + assigmentId); TOTAL_UPDATE++; } } } } } TempData["Messages"] = "Total Inserted = " + TOTAL_INSERT + " , Total Updated = " + TOTAL_UPDATE; } catch (Exception ex) { Console.WriteLine(ex.ToString()); TempData["Messages"] = ex.ToString(); } } System.IO.File.Delete(System.IO.Path.Combine(uploads, file.FileName)); return(RedirectToAction("Index")); }
/// <summary> /// 繫結 SLP_SLPDate JavaScript 事件 /// </summary> /// <param name="control_slp_DATE">SLP_DATE 物件</param> private void SetSLPDateClinetScript(ASP.wui_slp_slp_slpdate_ascx control_slp_DATE) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type=\"text/javascript\">\n"); sb.Append("//<![CDATA[\n"); sb.Append(" Sys.Application.add_load(" + control_slp_DATE.ClientID + "_SLPDateLoad);\n"); sb.Append(" function " + control_slp_DATE.ClientID + "_SLPDateLoad()\n"); sb.Append(" {\n"); sb.Append(" var TextBoxCodeID = '" + control_slp_DATE.DateTextBox.ClientID + "';\n"); sb.Append(" var CalFormat = '%Y/%m/%d';\n"); sb.Append(" var ImgID = '" + ((Image)control_slp_DATE.FindControl("Image1")).ClientID + "';\n"); sb.Append(" var RequiredVaildControl = $get('" + ((RequiredFieldValidator)control_slp_DATE.FindControl("RequiredFieldValidator1")).ClientID + "');\n"); sb.Append(" var CustomValidControl = $get('" + ((CustomValidator)control_slp_DATE.FindControl("CustomValidator1")).ClientID + "');\n"); sb.Append(" var IsRequiredHiddenControl = $get('" + ((System.Web.UI.HtmlControls.HtmlInputHidden)control_slp_DATE.FindControl("IsRequiredHidden")).ClientID + "');\n"); sb.Append(" if ($get('" + ((Image)control_slp_DATE.FindControl("Image1")).ClientID + "')!=null)\n"); sb.Append(" {\n"); sb.Append(" if ($get('" + ((TextBox)control_slp_DATE.FindControl("TextBoxCode")).ClientID + "').readOnly)\n"); sb.Append(" {\n"); sb.Append(" $get('" + ((Image)control_slp_DATE.FindControl("Image1")).ClientID + "').style.display = 'none';\n"); sb.Append(" }\n"); sb.Append(" SLPCalendarCreate(TextBoxCodeID,CalFormat,ImgID,RequiredVaildControl,CustomValidControl,IsRequiredHiddenControl);\n"); sb.Append(" }\n"); sb.Append(" if ($get(TextBoxCodeID) != null)\n"); sb.Append(" {\n"); sb.Append(" $get(TextBoxCodeID).onkeydown = " + control_slp_DATE.ClientID + "_Filter;//記錄keydown事件\n"); sb.Append(" }\n"); sb.Append(" }\n"); sb.Append(" function " + control_slp_DATE.ClientID + "_Filter()\n"); sb.Append(" {\n"); sb.Append(" if(event.keyCode == 13) //過濾按enter不動作\n"); sb.Append(" {\n"); sb.Append(" event.returnValue = false;\n"); sb.Append(" }\n"); sb.Append(" }\n"); sb.Append("\n"); sb.Append("//]]>\n"); sb.Append("</script>\n"); ScriptManager.RegisterStartupScript(Page, this.GetType(), control_slp_DATE.ClientID, sb.ToString(), false); }