public MemberMaster SignUp(RegisterViewModel model) { if (IsValid(model.UserName, model.Password)) { return(null); } var member = new MemberMaster { Email_Login = model.UserName, Password = model.Password, MemberRoleId = model.RoleId }; { member.RegisteredDate = DateTime.Now; member.RegisteredIP = UtilHelper.GetVisitorIPAddress(); member.ActivationCode = Crypto.HashPassword(model.Password); member.ActivationCodeExpired = DateTime.Now.AddDays(AppSettingsHelper.GetValue <int>(AppSettings.KEYS.ACCOUNT_ACTIVATION_EXPIRED_DAYS)); _repository.Insert(member); return(member); } }
protected void Page_Load(object sender, System.EventArgs e) { iconIBN.Attributes.Add("href", ResolveUrl("~/portal.ico")); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/Theme.css"); if (!PortalConfig.SystemIsActive) { lblText.InnerHtml = String.Format(CHelper.GetResFileString(GlobalResourceManager.Strings["BottomsTextResourceKey"]), Mediachase.Ibn.IbnConst.FullVersion); } else { if (!IsPostBack) { if (Request["sid"] != null) { ProcessSid(); } else if (Request["outlookticketid"] != null) { ProcessOutlook(); } else if (Request["login"] != null && Request["password"] != null) { ProcessLogin(); } else if (Request.IsAuthenticated) { ProcessRedirect(); } } Response.Redirect("Public/default.aspx", true); } }
private void RegisterScripts() { // Styles UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/Theme.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/ibn.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/mcCalendClient.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/mcBlockMenu.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/menuStyle.css"); // Scripts UtilHelper.RegisterScript(Page, "~/Scripts/IbnFramework/JsDebug.js"); UtilHelper.RegisterScript(Page, "~/Scripts/browser.js"); UtilHelper.RegisterScript(Page, "~/Scripts/buttons.js"); UtilHelper.RegisterScript(Page, "~/Scripts/common.js"); UtilHelper.RegisterScript(Page, "~/Scripts/toptabsnew.js"); if (loadExtJs) { CHelper.LoadExtJSGridScriptsToHead(Page); } CommonHelper.RegisterLocationScript(Page, sTitle); }
public static List <string> PrepSqlUpdateFields <T>(T model, List <string> fields = null, List <string> skipFields = null) where T : new() { // En el update no podemos modificar el campo 'createdDate' if (fields.Contains("createdDate")) { fields.Remove("createdDate"); } List <string> sql = new List <string>(); List <KeyValuePair <string, string> > list = SqlFields(model, fields, skipFields); List <string> keys = new List <string>(); string sqlField = null; foreach (KeyValuePair <string, string> obj in list) { keys.Add(obj.Key); sqlField = " [" + obj.Key + "] = " + obj.Value; sql.Add(sqlField); } if (fields == null || fields.Count == 0) { fields = UtilHelper.GetClassProperties(model); } string temp = "modifiedDate"; if (fields.Contains(temp) && !keys.Contains(temp)) { sqlField = " [" + temp + "] = [dbo].[Fn.TimeStamp.GetTimeStampDate]()"; sql.Add(sqlField); } return(sql); }
/// <summary> /// 模拟达达 /// </summary> /// <param name="orderCode"></param> /// <param name="url"></param> /// <returns></returns> private async Task <string> DadaSimulation(string orderCode, string url, string msg = null) { var appData = HttpContext.RequestServices.GetService <AppData>(); var trans = new DadaTrans { Timestamp = UtilHelper.ConvertDateTimeToInt(DateTime.Now) }; trans.App_key = appData.DadaAppKey; trans.App_secret = appData.DadaAppSecret; trans.Source_id = appData.DadaSourceId; trans.Body = JsonConvert.SerializeObject(new { order_id = orderCode, reason = msg }); trans.Generator(); using (var hc = new HttpClient()) { var p = JsonConvert.SerializeObject(trans, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); var body = new StringContent(p); body.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = await hc.PostAsync(appData.DadaDomain + url, body); return(await result.Content.ReadAsStringAsync()); } }
/// <summary> /// 根据线上仓名称查询可用线上仓信息。 /// </summary> /// <param name="storeName">线上仓名称,使用逗号(,)分隔。</param> /// <returns>包含重工线上仓信息的数据集对象。</returns> public DataSet GetReworkStore(string storeName) { DataSet dsReturn = new DataSet(); string sqlCommand = string.Empty; try { sqlCommand = @"SELECT A.STORE_KEY,A.STORE_NAME,A.STORE_TYPE FROM WST_STORE A WHERE 1=1 AND A.OBJECT_STATUS='1' "; if (!string.IsNullOrEmpty(storeName)) { sqlCommand = sqlCommand + UtilHelper.BuilderWhereConditionString("A.STORE_NAME", storeName.Split(',')); } sqlCommand = sqlCommand + " ORDER BY STORE_NAME"; dsReturn = db.ExecuteDataSet(CommandType.Text, sqlCommand); dsReturn.Tables[0].TableName = WST_STORE_FIELDS.DATABASE_TABLE_NAME; FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsReturn, ""); } catch (Exception ex) { FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsReturn, ex.Message); LogService.LogError("GetReworkStroe Error: " + ex.Message); } return(dsReturn); }
private void CheckUpdate() { CheckUpdateLoading = true; HttpHelper.GetAsync(new RequestGetModel <AppInfoModel> { Path = "/api/v1/sgw2/info", Query = new Dictionary <string, string> { { "version", Assembly.GetExecutingAssembly().GetName().Version.ToString() }, }, SuccessCallback = (res) => { var appInfo = res.result; LatestVersion = appInfo.version; LatestVersionSrc = appInfo.setupSrc; if (UtilHelper.GetVersionWeight(LatestVersion) <= UtilHelper.GetVersionWeight(Version)) { CheckUpdateText = "当前是最新版本"; } }, ErrorCallback = ex => { CheckUpdateText = "请求出错"; }, CompleteCallback = () => { new Thread(() => { Thread.Sleep(UtilHelper.GetRandomNumber(1000, 2000)); CheckUpdateLoading = false; }).Start(); } }); }
public IActionResult PutGrantPhone([FromBody] dynamic data) { var encrytedData = data.encrytedData.ToString(); var iv = data.iv.ToString(); var skey = int.Parse(Request.Headers["X-WX-Skey"]); var session = Service.Set <SessionData>().Find(skey); var sessionKey = session.SessionKey; var phoneMsg = UtilHelper.AESDecrypt(encrytedData, sessionKey, iv); var phone = JsonConvert.DeserializeObject <WxPhone>(phoneMsg); if (string.IsNullOrEmpty(phone.PurePhoneNumber)) { return(Ok(new WxRetInfo { Code = -1, Message = "微信未绑定手机号" })); } Service.GrantPhone(session.UserId, phone.PurePhoneNumber); return(Ok(new WxRetInfo { Data = phone.PurePhoneNumber })); }
private void PreparePage() { fckEditor.Language = Security.CurrentUser.Culture; fckEditor.EnableSsl = Request.IsSecureConnection; fckEditor.SslUrl = ResolveUrl("~/Common/Empty.html"); fckEditor.DesignModeCss = UtilHelper.ResolveUrl(Page, "~/Styles/IbnFramework/windows.css"); if (ArticleId > 0) { secHeader.Title = LocRM.GetString("tArticleEdit"); } else { secHeader.Title = LocRM.GetString("tArticleNew"); } btnSave.Text = LocRM2.GetString("Save"); btnCancel.Text = LocRM2.GetString("Cancel"); btnCancel.Attributes.Add("onclick", "DisableButtons(this);"); btnSave.Attributes.Add("onclick", "DisableButtons(this);"); btnSave.CustomImage = Page.ResolveUrl("~/Layouts/Images/saveitem.gif"); secHeader.AddImageLink(Page.ResolveUrl("~/Layouts/Images/cancel.gif"), LocRM.GetString("atclBackToList"), Page.ResolveUrl("~/Apps/HelpDeskManagement/Pages/ArticleListMain.aspx")); }
/// <summary> /// Returns formatted string back /// </summary> /// <param name="date"></param> /// <returns></returns> public static string FormatDateTime(DateTime date) { string formatted = ""; DateTime userUtcNow = GetUserDateTimeNow(); DateTime userDate = GetUserDateTime(date); // make Today and Yesterday bold if ((userDate.DayOfYear == userUtcNow.DayOfYear) && (userDate.Year == userUtcNow.Year)) { formatted = "<b>" + UtilHelper.GetResFileString("{SharedStrings:Today}") + "</b>, "; formatted += userDate.ToString("t"); } else if ((userDate.DayOfYear == (userUtcNow.DayOfYear - 1)) && (userDate.Year == userUtcNow.Year)) { formatted = "<b>" + UtilHelper.GetResFileString("{SharedStrings:Yesterday}") + "</b>, "; formatted += userDate.ToString("t"); } else { formatted = userDate.ToString(); } return(formatted); }
protected void Page_Load(object sender, System.EventArgs e) { UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/Theme.css"); UtilHelper.RegisterScript(Page, "~/Scripts/browser.js"); UtilHelper.RegisterScript(Page, "~/Scripts/buttons.js"); UtilHelper.RegisterScript(Page, "~/Scripts/common.js"); lbUsers.Attributes.Add("ondblclick", "DisableButtons(this);" + Page.ClientScript.GetPostBackEventReference(btnAdd, "")); //btnSave.Attributes.Add("onclick","DisableButtons(this);"); btnAdd.Attributes.Add("onclick", "DisableButtons(this);"); btnAddGroup.Attributes.Add("onclick", "DisableButtons(this);"); if (cbConfirmed.Checked) { btnAddGroup.Style.Add("display", "none"); } else { btnAddGroup.Style.Add("display", "inline"); } lblError.Visible = false; if (!IsPostBack) { ViewState["SearchMode"] = false; cbConfirmed.Text = LocRM.GetString("MustBeConfirmed"); btnAdd.InnerText = LocRM.GetString("Add"); btnAddGroup.InnerText = LocRM.GetString("AddGroup"); btnSearch.Text = LocRM.GetString("FindNow"); lblError.Text = LocRM.GetString("EmrtySearch"); GetEventData(); BindGroups(); BinddgMemebers(); } cbConfirmed.Attributes.Add("onclick", "ChangeButtonState();"); }
private string GetBaseInfo() { String result = ""; context.Response.ContentType = "application/json"; DataClassesDataContext dc = new DataClassesDataContext(); string id; if (context.Request.Params["aplID"] != null) { id = context.Request.Params["aplID"]; ViewPosApl exs = dc.ViewPosApl.SingleOrDefault(es => es.F_ID.Equals(id)); result = UtilHelper.GetJSON(exs); } else { id = context.Session[SessionMgm.UserID].ToString(); // 当前登录用户即该业务的申请者 User usr = dc.User.SingleOrDefault(es => es.F_ID.Equals(id)); result = UtilHelper.GetJSON(usr); result = result.Replace("F_ID", "F_UserID"); } return(result); }
public ActionResult GetPhotoPeople(int id) { if (id <= 0) { return(null); } PeopleViewModel peopleModel; try { peopleModel = repository.GetPeople(id); if (peopleModel == null) { return(null); } return(File(UtilHelper.HttpPostedFileBaseToByte(peopleModel.PhotoPeople), peopleModel.PhotoMIMEType)); } catch { return(null); } }
/// <summary> /// 新订单 /// </summary> /// <returns></returns> public async Task <IActionResult> Order([FromServices] IThirdOrderRepository service) { var business = await service.GetBusinessByMtPoi(formDic["app_poi_code"]); if (business == null || !business.MT_AutoRecieved) { return(Json(new { data = "ok" })); } //Log.Debug($"美团[新]订单:{business.Name}-{formDic["app_poi_code"]}-{formDic["day_seq"]}"); // 如果设置了美团自动接单,则调用商户确认接口 var url = "https://waimaiopen.meituan.com/api/v1/order/confirm"; var mt = new MTInputData(business.MT_AppKey, url); mt.SetValue("timestamp", DateTime.Now.ToTimestamp()); mt.SetValue("app_id", business.MT_AppId); mt.SetValue("order_id", formDic["order_id"]); var sig = mt.MakeSign(); mt.SetValue("sig", sig); url = $"{url}?{mt.ToUrl()}"; await UtilHelper.RequestAsync(url, method : "get"); return(Json(new { data = "ok" })); }
private void Install(string name) { var TempAddonList = _ConfigManager.GetAddonList(GameType); var willInstallAddon = TempAddonList.Find(item => item.name == name); var applicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (willInstallAddon == null) { return; } if (!string.IsNullOrEmpty(willInstallAddon.limitExeVersion)) { if (UtilHelper.GetVersionWeight(applicationVersion) < UtilHelper.GetVersionWeight(willInstallAddon.limitExeVersion)) { UtilHelper.ShowAlertDialog(new AlertDialogInterfaceModel { Content = "StartGuildwars2 版本太低,请先更新" }); return; } } var willInstallAddonList = GetWillInstallList(name); var steps = new List <AddonStepModel>(); foreach (var willInstallAddonName in willInstallAddonList) { steps.Add(new AddonStepModel { Action = "INSTALL", AddonName = willInstallAddonName, }); } ShowAddonProgressDialog(steps); }
//Atomic functions area private int ByConstructor(Type type) { //validation for auto-generated inner-classes for events if (UtilHelper.IsSameOrSubclass(typeof(MulticastDelegate), type)) { return(0); } int count = 0; var ctors = type.GetConstructors(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); switch (ComplementValue) { case nameof(Constructor.NoArgs): foreach (ConstructorInfo ctor in ctors) { if (ctor.GetParameters().Count() == 0) { count++; } } break; case nameof(Constructor.WithArgs): foreach (ConstructorInfo ctor in ctors) { if (ctor.GetParameters().Count() > 0) { count++; } } break; } return(count); }
private string GetTopMenuWelcomeText(string resourceString) { string fullName = CustomerContext.Current.CurrentContact.FullName; return(string.Format("{0}, {1}", (object)UtilHelper.GetResFileString(resourceString), string.IsNullOrEmpty(fullName) ? (object)SecurityContext.Current.CurrentUserName : (object)fullName)); }
private void BindFromObject(ToolBarItem[] itemCollection, List <McToolbarItem> toolbarItemsCollection) { if (itemCollection == null) { return; } foreach (ToolBarItem toolBarItem in itemCollection) { McToolbarItem mcToolbarItem1 = new McToolbarItem(); if (toolBarItem is Menu) { mcToolbarItem1.ItemType = McToolbarItemType.Menu; } else if (toolBarItem is Button) { mcToolbarItem1.ItemType = McToolbarItemType.Button; } else if (toolBarItem is SplitButton) { mcToolbarItem1.ItemType = McToolbarItemType.SplitButton; } else if (toolBarItem is Text) { mcToolbarItem1.ItemType = McToolbarItemType.Text; } else if (toolBarItem is Splitter) { mcToolbarItem1.ItemType = McToolbarItemType.Splitter; } McToolbarItemAlign toolbarItemAlign = McToolbarItemAlign.Left; McToolbarItemSplitter toolbarItemSplitter = McToolbarItemSplitter.None; if (!string.IsNullOrEmpty(toolBarItem.align)) { try { toolbarItemAlign = (McToolbarItemAlign)Enum.Parse(typeof(McToolbarItemAlign), toolBarItem.align); } catch { throw; } } if (!string.IsNullOrEmpty(toolBarItem.itemSplitter)) { try { toolbarItemSplitter = (McToolbarItemSplitter)Enum.Parse(typeof(McToolbarItemSplitter), toolBarItem.itemSplitter); } catch { throw; } } if (toolBarItem.imageUrl != string.Empty && (mcToolbarItem1.ItemType == McToolbarItemType.Button || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton || mcToolbarItem1.ItemType == McToolbarItemType.Menu)) { mcToolbarItem1.CssClass += "x-btn-wrap x-btn x-btn-text-icon "; } mcToolbarItem1.Id = toolBarItem.id; mcToolbarItem1.Text = this.IsTopMenuWelcomeText(toolBarItem.text) ? this.GetTopMenuWelcomeText(toolBarItem.text) : UtilHelper.GetResFileString(toolBarItem.text); mcToolbarItem1.ImageUrl = this.ResolveClientUrl(toolBarItem.imageUrl); mcToolbarItem1.CssClass += toolBarItem.cssClass; mcToolbarItem1.ItemAlign = toolbarItemAlign; mcToolbarItem1.Handler = toolBarItem.handler; mcToolbarItem1.Tooltip = UtilHelper.GetResFileString(toolBarItem.tooltip); bool isEnabled = true; if (!string.IsNullOrEmpty(toolBarItem.commandName)) { CommandParameters cp = new CommandParameters(toolBarItem.commandName); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("GridId", this.GridId); dictionary.Add("GridClientId", this.GridClientId); dictionary.Add("permissions", toolBarItem.permissions); if (!string.IsNullOrEmpty(this.ContainerId)) { dictionary.Add("ContainerId", this.ContainerId); } cp.CommandArguments = dictionary; string str = CommandManager.GetCurrent(this.Page).AddCommand(this.ClassName, this.ViewName, this.PlaceName, cp, out isEnabled); dictionary.Add("CommandManagerScript", str); cp.CommandArguments = dictionary; mcToolbarItem1.Params = cp.ToString(); mcToolbarItem1.Handler = "defaultToolbarOnClick"; } if (mcToolbarItem1.ItemType == McToolbarItemType.Menu || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton) { if (toolBarItem is Menu) { this.BindFromObject((toolBarItem as Menu).Items, mcToolbarItem1.Items); } else if (toolBarItem is SplitButton) { this.BindFromObject((toolBarItem as SplitButton).Items, mcToolbarItem1.Items); } } if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Left)) { McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter); mcToolbarItem2.ItemAlign = toolbarItemAlign; toolbarItemsCollection.Add(mcToolbarItem2); } if (isEnabled) { toolbarItemsCollection.Add(mcToolbarItem1); } if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Right)) { McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter); mcToolbarItem2.ItemAlign = toolbarItemAlign; toolbarItemsCollection.Add(mcToolbarItem2); } } }
//ds为柜明细表中取值的托信息的数据集,dt为前台gridview中的数据 public DataSet UpdateArkInf(DataSet ds, DataTable dt, int flag) { DataSet retDS = new DataSet(); DbConnection dbCon = db.CreateConnection(); dbCon.Open(); DbTransaction dbTrans = dbCon.BeginTransaction(); string sql = string.Empty; try { #region //0.判定柜是是新组柜还是已经存在的柜 // 无托信息柜组柜 //1.新增信息到柜抬头表 //2.新增组柜信息到明细表 //3.修改包装表中托状态为已组柜1 if (flag == 1) { string key = UtilHelper.GenerateNewKey(0); DataTable dtHash = ds.Tables["HASH"]; Hashtable hsTable = FanHai.Hemera.Share.Common.CommonUtils.ConvertToHashtable(dtHash); string sql01 = string.Format(@"INSERT INTO AWMS_CONTAINER(CONTAINER_KEY,CONTAINER_CODE,STATUS) VALUES('{0}','{1}','0')", key, hsTable["CONTAINER_CODE"].ToString() ); db2.ExecuteNonQuery(CommandType.Text, sql01); if (dt != null) { string sql02 = string.Format(@"SELECT CONTAINER_KEY,CONTAINER_CODE FROM AWMS_CONTAINER WHERE STATUS = '0' AND CONTAINER_CODE ='{0}'", hsTable["CONTAINER_CODE"].ToString()); DataSet ds02 = db2.ExecuteDataSet(CommandType.Text, sql02); for (int i = 0; i < dt.Rows.Count; i++) { string sql03 = string.Format(@"INSERT INTO AWMS_CONTAINER_DETAIL(CONTAINER_KEY,CONTAINER_CODE,PALLET_NO,CREATOR,CDATE,STATUS) VALUES('{0}','{1}','{2}','{3}',GETDATE(),'1')", ds02.Tables[0].Rows[0]["CONTAINER_KEY"].ToString(), ds02.Tables[0].Rows[0]["CONTAINER_CODE"].ToString(), dt.Rows[i]["PALLET_NO"], hsTable["CREATOR"].ToString() ); db2.ExecuteNonQuery(CommandType.Text, sql03); } DataTable dt04 = dt; string strPlus = string.Empty; for (int i = 0; i < dt04.Rows.Count; i++) { strPlus += "'" + dt04.Rows[i]["PALLET_NO"].ToString().Trim() + "',"; } if (string.IsNullOrEmpty(strPlus)) { strPlus = "'',"; } string str = strPlus.Substring(0, strPlus.Length - 1); string sql04 = string.Format(@"UPDATE WIP_CONSIGNMENT SET ARK_FLAG = '1' WHERE PALLET_NO IN({0})", str ); db.ExecuteNonQuery(CommandType.Text, sql04); dbTrans.Commit(); FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(retDS, string.Empty); } } #endregion // 有柜组柜 // 明细表中没有托信息则不执行1 2两步 //1.删除明细表中该柜主键的所有托信息 //2.修改包装表中对应的托状态为未组柜0 //3.新增组柜托信息到明细表 //4.修改包装表中对应托状态为已组柜1 else if (flag == 0) { string key = UtilHelper.GenerateNewKey(0); DataTable dtHash = ds.Tables["HASH"]; Hashtable hsTable = FanHai.Hemera.Share.Common.CommonUtils.ConvertToHashtable(dtHash); #region if (dt != null) { string sql01 = string.Format(@"SELECT CONTAINER_KEY,CONTAINER_CODE FROM AWMS_CONTAINER WHERE STATUS = '0' AND CONTAINER_CODE ='{0}'" , hsTable["CONTAINER_CODE"].ToString()); DataSet ds01 = db2.ExecuteDataSet(CommandType.Text, sql01); if (ds01 != null) { if (ds01.Tables[0].Rows.Count == 1) { string sql02 = string.Format(@"SELECT PALLET_NO FROM AWMS_CONTAINER_DETAIL WHERE CONTAINER_KEY = '{0}'" , ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString()); DataSet ds02 = db2.ExecuteDataSet(CommandType.Text, sql02); string sql03 = string.Format(@"DELETE FROM AWMS_CONTAINER_DETAIL WHERE CONTAINER_KEY = '{0}'" , ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString()); db2.ExecuteNonQuery(CommandType.Text, sql03); string strPlus04 = string.Empty; DataTable dt04 = ds02.Tables[0]; for (int i = 0; i < dt04.Rows.Count; i++) { strPlus04 += "'" + dt04.Rows[i]["PALLET_NO"].ToString().Trim() + "',"; } if (string.IsNullOrEmpty(strPlus04)) { strPlus04 = "'',"; } string str04 = strPlus04.Substring(0, strPlus04.Length - 1); string sql04 = string.Format(@"UPDATE WIP_CONSIGNMENT SET ARK_FLAG = '0' WHERE PALLET_NO IN({0})" , str04); db.ExecuteNonQuery(CommandType.Text, sql04); for (int i = 0; i < dt.Rows.Count; i++) { string sql05 = string.Format(@"INSERT INTO AWMS_CONTAINER_DETAIL(CONTAINER_KEY,CONTAINER_CODE,PALLET_NO,CREATOR,CDATE,STATUS) VALUES('{0}','{1}','{2}','{3}',GETDATE(),'1')", ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString(), ds01.Tables[0].Rows[0]["CONTAINER_CODE"].ToString(), dt.Rows[i]["PALLET_NO"], hsTable["CREATOR"].ToString() ); db2.ExecuteNonQuery(CommandType.Text, sql05); } DataTable dt06 = dt; string strPlus06 = string.Empty; for (int i = 0; i < dt06.Rows.Count; i++) { strPlus06 += "'" + dt06.Rows[i]["PALLET_NO"].ToString().Trim() + "',"; } if (string.IsNullOrEmpty(strPlus06)) { strPlus06 = "'',"; } string str06 = strPlus06.Substring(0, strPlus06.Length - 1); string sql06 = string.Format(@"UPDATE WIP_CONSIGNMENT SET ARK_FLAG = '1' WHERE PALLET_NO IN({0})", str06 ); db.ExecuteNonQuery(CommandType.Text, sql06); } else { for (int i = 0; i < dt.Rows.Count; i++) { string sql05 = string.Format(@"INSERT INTO AWMS_CONTAINER_DETAIL(CONTAINER_KEY,CONTAINER_CODE,PALLET_NO,CREATOR,CDATE,STATUS) VALUES('{0}','{1}','{2}','{3}',GETDATE(),'1')", ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString(), ds01.Tables[0].Rows[0]["CONTAINER_CODE"].ToString(), dt.Rows[i]["PALLET_NO"], hsTable["CREATOR"].ToString() ); db2.ExecuteNonQuery(CommandType.Text, sql05); } DataTable dt06 = dt; string strPlus06 = string.Empty; for (int i = 0; i < dt06.Rows.Count; i++) { strPlus06 += "'" + dt06.Rows[i]["PALLET_NO"].ToString().Trim() + "',"; } if (string.IsNullOrEmpty(strPlus06)) { strPlus06 = "'',"; } string str06 = strPlus06.Substring(0, strPlus06.Length - 1); string sql06 = string.Format(@"UPDATE WIP_CONSIGNMENT SET ARK_FLAG = '1' WHERE PALLET_NO IN({0})", str06 ); db.ExecuteNonQuery(CommandType.Text, sql06); } } dbTrans.Commit(); FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(retDS, string.Empty); } #endregion ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (dt == null) { string sql01 = string.Format(@"SELECT CONTAINER_KEY,CONTAINER_CODE FROM AWMS_CONTAINER WHERE STATUS = '0' AND CONTAINER_CODE ='{0}'" , hsTable["CONTAINER_CODE"].ToString()); DataSet ds01 = db2.ExecuteDataSet(CommandType.Text, sql01); if (ds01 != null) { if (ds01.Tables[0].Rows.Count == 1) { string sql02 = string.Format(@"SELECT PALLET_NO FROM AWMS_CONTAINER_DETAIL WHERE CONTAINER_KEY = '{0}'" , ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString()); DataSet ds02 = db2.ExecuteDataSet(CommandType.Text, sql02); string sql03 = string.Format(@"DELETE FROM AWMS_CONTAINER_DETAIL WHERE CONTAINER_KEY = '{0}'" , ds01.Tables[0].Rows[0]["CONTAINER_KEY"].ToString()); db2.ExecuteNonQuery(CommandType.Text, sql03); string strPlus04 = string.Empty; DataTable dt04 = ds02.Tables[0]; for (int i = 0; i < dt04.Rows.Count; i++) { strPlus04 += "'" + dt04.Rows[i]["PALLET_NO"].ToString().Trim() + "',"; } if (string.IsNullOrEmpty(strPlus04)) { strPlus04 = "'',"; } string str04 = strPlus04.Substring(0, strPlus04.Length - 1); string sql04 = string.Format(@"UPDATE WIP_CONSIGNMENT SET ARK_FLAG = '0' WHERE PALLET_NO IN({0})" , str04); db.ExecuteNonQuery(CommandType.Text, sql04); dbTrans.Commit(); FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(retDS, string.Empty); } } } } } catch (Exception ex) { dbTrans.Rollback(); FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(retDS, ex.Message); LogService.LogError("UpdateArkInf Error: " + ex.Message); } return(retDS); }
/// <summary> /// 转返工单作业。 /// </summary> /// <param name="dsParams"></param> /// <returns></returns> public DataSet LotExchange(DataSet dsParams) { DataSet dsReturn = new DataSet(); //参数数据。 if (dsParams == null || !dsParams.Tables.Contains(TRANS_TABLES.TABLE_PARAM) || //存放附加参数数据 !dsParams.Tables.Contains(POR_LOT_FIELDS.DATABASE_TABLE_NAME) //存放批次数据 ) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, "传入参数不正确,请检查。"); return(dsReturn); } try { DataTable dtParams = dsParams.Tables[TRANS_TABLES.TABLE_PARAM]; DataTable dtLots = dsParams.Tables[POR_LOT_FIELDS.DATABASE_TABLE_NAME]; Hashtable htParams = CommonUtils.ConvertToHashtable(dtParams); string editor = Convert.ToString(htParams[POR_LOT_FIELDS.FIELD_EDITOR]); //编辑人 string opComputer = Convert.ToString(htParams[POR_LOT_FIELDS.FIELD_OPR_COMPUTER]); //编辑人 string enterpriseKey = Convert.ToString(htParams[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); string routeKey = Convert.ToString(htParams[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string stepKey = Convert.ToString(htParams[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); string activity = Convert.ToString(htParams[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY]); using (DbConnection dbConn = db.CreateConnection()) { dbConn.Open(); using (DbTransaction dbTran = dbConn.BeginTransaction()) { foreach (DataRow dr in dtLots.Rows) { string lotKey = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_KEY]); string lotNumber = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]); string ttime = Convert.ToString(dr[WIP_IV_TEST_FIELDS.FIELDS_T_DATE]); string palletNo = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_PALLET_NO]); //检查记录是否过期。防止重复修改。 KeyValuePair <string, string> kvp = new KeyValuePair <string, string>(POR_LOT_FIELDS.FIELD_LOT_KEY, lotKey); List <KeyValuePair <string, string> > listCondition = new List <KeyValuePair <string, string> >(); listCondition.Add(kvp); string opEditTime = Convert.ToString(dr[POR_LOT_FIELDS.FIELD_EDIT_TIME]); //如果记录过期,当前编辑时间<数据库中的记录编辑时间。结束方法执行。 if (UtilHelper.CheckRecordExpired(db, POR_LOT_FIELDS.DATABASE_TABLE_NAME, listCondition, opEditTime)) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, string.Format("组件{0}信息已过期,请确认。", lotNumber)); return(dsReturn); } //获取批次数据 string sqlQueryLot = string.Format(@"SELECT A.*, B.ENTERPRISE_NAME, B.ENTERPRISE_VERSION, C.ROUTE_NAME , D.ROUTE_STEP_NAME FROM POR_LOT A LEFT JOIN POR_ROUTE_ENTERPRISE_VER B ON B.ROUTE_ENTERPRISE_VER_KEY= A.ROUTE_ENTERPRISE_VER_KEY LEFT JOIN POR_ROUTE_ROUTE_VER C ON C.ROUTE_ROUTE_VER_KEY=A.CUR_ROUTE_VER_KEY LEFT JOIN POR_ROUTE_STEP D ON D.ROUTE_STEP_KEY=A.CUR_STEP_VER_KEY WHERE A.STATUS < 2 AND A.LOT_NUMBER='{0}'", lotNumber.PreventSQLInjection()); DataTable dtTable = db.ExecuteDataSet(dbTran, CommandType.Text, sqlQueryLot).Tables[0]; DataRow drLotInfo = dtTable.Rows[0]; string transactionKey = CommonUtils.GenerateNewKey(0); AddWIPLot(dbTran, transactionKey, lotKey); //向WIP_TRANSACTION表插入批次转返工单的操作记录。 Hashtable htTransaction = new Hashtable(); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY, transactionKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY, activity); if (htParams.Contains(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT)) { htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT, htParams[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT]); } htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIME, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_EDIT_TIMEZONE]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDITOR, htParams[WIP_TRANSACTION_FIELDS.FIELD_EDITOR]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_NAME, drLotInfo[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EQUIPMENT_KEY, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPERATOR, editor); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_COMPUTER, opComputer); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE_PRE, drLotInfo[POR_LOT_FIELDS.FIELD_LINE_NAME]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_LOT_KEY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_PIECE_TYPE, 0); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN, drLotInfo[POR_LOT_FIELDS.FIELD_QUANTITY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT, drLotInfo[POR_LOT_FIELDS.FIELD_QUANTITY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG, drLotInfo[POR_LOT_FIELDS.FIELD_IS_REWORKED]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_NAME, drLotInfo[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_KEY, htParams[WIP_TRANSACTION_FIELDS.FIELD_SHIFT_KEY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME, htParams[WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STATE_FLAG, drLotInfo[POR_LOT_FIELDS.FIELD_STATE_FLAG]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME, drLotInfo[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TIME_STAMP, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY, drLotInfo[POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY]); WIP_TRANSACTION_FIELDS wipFields = new WIP_TRANSACTION_FIELDS(); string sql = DatabaseTable.BuildInsertSqlStatement(wipFields, htTransaction, null); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //更新批次数据 string updateLot = string.Format(@"UPDATE POR_LOT SET STATE_FLAG=0, {12} DELETED_TERM_FLAG=0, ROUTE_ENTERPRISE_VER_KEY='{1}', CUR_ROUTE_VER_KEY='{2}', CUR_STEP_VER_KEY='{3}', EDITOR='{4}', EDIT_TIME=GETDATE(), FACTORYROOM_KEY='{5}', FACTORYROOM_NAME='{6}', WORK_ORDER_NO='{7}', WORK_ORDER_KEY='{8}', PART_NUMBER='{9}', PRO_ID='{10}', CUR_PRODUCTION_LINE_KEY=NULL, LINE_NAME=NULL, START_WAIT_TIME=GETDATE(), START_PROCESS_TIME=NULL, PALLET_NO=NULL, PALLET_TIME=NULL, OPR_COMPUTER='{4}', OPR_LINE=NULL, OPERATOR='{11}' WHERE LOT_KEY='{0}'", lotKey.PreventSQLInjection(), enterpriseKey.PreventSQLInjection(), routeKey.PreventSQLInjection(), stepKey.PreventSQLInjection(), editor.PreventSQLInjection(), dr[POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY], dr[POR_LOT_FIELDS.FIELD_FACTORYROOM_NAME], dr["NEW_WORK_ORDER_NO"], dr["NEW_WORK_ORDER_KEY"], dr["NEW_PART_NUMBER"], dr["NEW_PRO_ID"], opComputer.PreventSQLInjection(), activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CHANGE_PROID? "REWORK_FLAG=REWORK_FLAG+1," : string.Empty); this.db.ExecuteNonQuery(dbTran, CommandType.Text, updateLot); //如果有有效测试数据,更新测试数据 if (!string.IsNullOrEmpty(ttime)) { string updateIVTest = string.Format(@"UPDATE WIP_IV_TEST SET VC_TYPE='{1}',I_IDE='{2}',I_PKID='{3}',VC_MODNAME='{4}',VC_WORKORDER='{5}' WHERE LOT_NUM='{0}' AND VC_DEFAULT='1'", lotNumber.PreventSQLInjection(), dr[WIP_IV_TEST_FIELDS.FIELDS_VC_TYPE], dr[WIP_IV_TEST_FIELDS.FIELDS_I_IDE], dr[WIP_IV_TEST_FIELDS.FIELDS_I_PKID], dr[WIP_IV_TEST_FIELDS.FIELDS_VC_MODNAME], dr["NEW_WORK_ORDER_NO"]); this.db.ExecuteNonQuery(dbTran, CommandType.Text, updateIVTest); } } //更新包装数据。 var lnq = dtLots.AsEnumerable().Where(dr => string.IsNullOrEmpty(Convert.ToString(dr[POR_LOT_FIELDS.FIELD_PALLET_NO])) == false) .Select(dr => Convert.ToString(dr[POR_LOT_FIELDS.FIELD_PALLET_NO])) .Distinct(); foreach (string palletNo in lnq) { string consignmentKey = CommonUtils.GenerateNewKey(0); //新增包装明细数据 string sql = string.Format(@"INSERT INTO WIP_CONSIGNMENT_DETAIL (CONSIGNMENT_KEY,ITEM_NO,LOT_NUMBER,WORK_NUMBER,PART_NUMBER,PRO_ID,PRO_LEVEL, COLOR,POWER_LEVEL,PS_CODE,PS_DTL_CODE,FULL_QTY,PS_SEQ,AVG_POWER_RANGE,CREATOR,CREATE_TIME) SELECT '{0}', ROW_NUMBER() OVER(PARTITION BY a.CONSIGNMENT_KEY ORDER BY b.ITEM_NO) ITEM_NO, b.LOT_NUMBER, b.WORK_NUMBER, b.PART_NUMBER, b.PRO_ID, b.PRO_LEVEL, b.COLOR, b.POWER_LEVEL, b.PS_CODE, b.PS_DTL_CODE, b.FULL_QTY, b.PS_SEQ, b.AVG_POWER_RANGE, b.CREATOR, b.CREATE_TIME FROM WIP_CONSIGNMENT a INNER JOIN WIP_CONSIGNMENT_DETAIL b ON b.CONSIGNMENT_KEY=a.CONSIGNMENT_KEY INNER JOIN POR_LOT c ON c.PALLET_NO=a.VIRTUAL_PALLET_NO AND c.LOT_NUMBER=b.LOT_NUMBER WHERE a.ISFLAG=1 AND a.PALLET_NO='{1}'", consignmentKey, palletNo.PreventSQLInjection()); this.db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //新增包装数据 sql = string.Format(@"INSERT INTO WIP_CONSIGNMENT(CONSIGNMENT_KEY,VIRTUAL_PALLET_NO,PALLET_NO,WORKNUMBER,CS_DATA_GROUP, SAP_NO,POWER_LEVEL,GRADE,SHIFT,PS_CODE,PS_DTL_SUBCODE, LAST_PALLET,CREATER,CREATE_TIME,EDITOR,EDIT_TIME,ISFLAG, ROOM_KEY,CUSTOMER_NO,LOT_NUMBER_QTY,FULL_QTY,TOTLE_POWER, AVG_POWER,PRO_ID,PALLET_NO_NEW,PALLET_TYPE, CODE_TYPE,LINE_NAME,LINE_KEY,EQUIPMENT_KEY,EQUIPMENT_NAME, AVG_POWER_RANGE,LOT_COLOR,PS_SEQ,CHECKER,CHECK_TIME, TO_WH,TO_WH_TIME,OUT_WH,OUT_WH_TIME,MEMO1,ARK_FLAG) SELECT '{0}', a.VIRTUAL_PALLET_NO,a.PALLET_NO,a.WORKNUMBER,a.CS_DATA_GROUP, a.SAP_NO,a.POWER_LEVEL,a.GRADE,a.SHIFT,a.PS_CODE,a.PS_DTL_SUBCODE, a.LAST_PALLET,a.CREATER,a.CREATE_TIME,'{2}',GETDATE(),a.ISFLAG, a.ROOM_KEY,a.CUSTOMER_NO,a.LOT_NUMBER_QTY,a.FULL_QTY,a.TOTLE_POWER, a.AVG_POWER,a.PRO_ID,a.PALLET_NO_NEW,a.PALLET_TYPE, a.CODE_TYPE,a.LINE_NAME,a.LINE_KEY,a.EQUIPMENT_KEY,a.EQUIPMENT_NAME, a.AVG_POWER_RANGE,a.LOT_COLOR,a.PS_SEQ,a.CHECKER,a.CHECK_TIME, a.TO_WH,a.TO_WH_TIME,a.OUT_WH,a.OUT_WH_TIME,a.MEMO1,a.ARK_FLAG FROM WIP_CONSIGNMENT a WHERE a.ISFLAG=1 AND a.PALLET_NO='{1}'", consignmentKey, palletNo.PreventSQLInjection(), editor.PreventSQLInjection()); this.db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //更新原来的包装数据为无效 sql = string.Format(@"UPDATE WIP_CONSIGNMENT SET ISFLAG=0,EDITOR='{2}',EDIT_TIME=GETDATE(),MEMO1='转/返工单 {3} {4}' WHERE ISFLAG=1 AND PALLET_NO='{1}' AND CONSIGNMENT_KEY!='{0}'", consignmentKey, palletNo.PreventSQLInjection(), editor.PreventSQLInjection(), activity, htParams[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT]); this.db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //更新现有的包装数据,为其第一条数据的基本数据 sql = string.Format(@"UPDATE a SET a.WORKNUMBER=b.WORK_NUMBER, a.SAP_NO=b.PART_NUMBER, a.POWER_LEVEL=b.POWER_LEVEL, a.GRADE=b.PRO_LEVEL, a.PS_CODE=b.PS_CODE, a.PS_DTL_SUBCODE=b.PS_DTL_CODE, a.LOT_NUMBER_QTY=(SELECT COUNT(1) FROM WIP_CONSIGNMENT_DETAIL aa WHERE aa.CONSIGNMENT_KEY=a.CONSIGNMENT_KEY), a.FULL_QTY=b.FULL_QTY, a.TOTLE_POWER=(SELECT ISNULL(SUM(bb.COEF_PMAX),0) FROM WIP_CONSIGNMENT_DETAIL aa INNER JOIN WIP_IV_TEST bb ON bb.LOT_NUM=aa.LOT_NUMBER AND bb.VC_DEFAULT='1' WHERE aa.CONSIGNMENT_KEY=a.CONSIGNMENT_KEY), a.PRO_ID=b.PRO_ID, a.LOT_COLOR=b.COLOR, a.PS_SEQ=b.PS_SEQ, a.AVG_POWER_RANGE=b.AVG_POWER_RANGE FROM WIP_CONSIGNMENT a LEFT JOIN WIP_CONSIGNMENT_DETAIL b ON b.CONSIGNMENT_KEY=a.CONSIGNMENT_KEY AND b.ITEM_NO=1 WHERE a.CONSIGNMENT_KEY='{0}'", consignmentKey); this.db.ExecuteNonQuery(dbTran, CommandType.Text, sql); sql = string.Format(@"UPDATE a SET a.AVG_POWER=CASE WHEN a.LOT_NUMBER_QTY=0 THEN 0 ELSE a.TOTLE_POWER/a.LOT_NUMBER_QTY END, a.ISFLAG=CASE WHEN a.LOT_NUMBER_QTY>0 THEN 1 ELSE 0 END FROM WIP_CONSIGNMENT a WHERE a.CONSIGNMENT_KEY='{0}'", consignmentKey); this.db.ExecuteNonQuery(dbTran, CommandType.Text, sql); } dbTran.Commit(); } dbConn.Close(); } } catch (Exception ex) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, ex.Message); LogService.LogError("LotOperationEngine.LotExchange Error: " + ex.Message); } return(dsReturn); }
/// <summary> /// Adds the acl group. /// </summary> /// <param name="group">The group.</param> /// <param name="treeNode">The tree node.</param> /// <returns></returns> private int AddAclGroup(AclGroup group, TreeNode treeNode) { int childrenChecked = -1; // 1 - checked, 2 - unchecked, 0 - some checked, -1 - not set TreeNode groupNode = new TreeNode(); groupNode.Value = GetTreeNodeUniqueId(_groupNodePrefix, group.ID); groupNode.Text = UtilHelper.GetResFileString(group.Name); groupNode.ShowCheckBox = true; groupNode.ImageUrl = Page.ResolveUrl("~/Apps/Profile/images/security_folder.png"); groupNode.SelectAction = TreeNodeSelectAction.Expand; treeNode.ChildNodes.Add(groupNode); // add child groups foreach (AclGroup childGroup in group.Groups) { int result = AddAclGroup(childGroup, groupNode); if (result == 2 && childrenChecked == 1) { childrenChecked = 0; } else if (result == 2 && childrenChecked == -1) { childrenChecked = 2; } else if (result == 1 && childrenChecked == -1) { childrenChecked = 1; } else if (result == 1 && childrenChecked == 2) { childrenChecked = 0; } else if (result == 0) { childrenChecked = 0; } } // add permissions foreach (AclPermission permission in group.Permissions) { TreeNode permissionNode = new TreeNode(); permissionNode.Value = GetTreeNodeUniqueId(_permissionNodePrefix, permission.ToString()); permissionNode.Text = UtilHelper.GetResFileString(permission.Name); permissionNode.SelectAction = TreeNodeSelectAction.None; permissionNode.ImageUrl = Page.ResolveUrl("~/Apps/Profile/images/security_key.png"); // check node if permission is set if (_Permission != null) { PermissionDto.RolePermissionRow[] permissionRows = (PermissionDto.RolePermissionRow[])_Permission.RolePermission.Select(String.Format("Permission='{0}'", permission.ToString())); if (permissionRows != null && permissionRows.Length > 0) { permissionNode.Checked = true; if (childrenChecked == -1) { childrenChecked = 1; } } } if (!permissionNode.Checked && childrenChecked == 1) { childrenChecked = 0; } if (!permissionNode.Checked && childrenChecked == -1) { childrenChecked = 2; } groupNode.ChildNodes.Add(permissionNode); } groupNode.Checked = childrenChecked == 1; if (childrenChecked == 0) { groupNode.Select(); groupNode.Expand(); } else { groupNode.Collapse(); } return(childrenChecked); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { //set application name to page title Literal1.Text = String.Format("{0} - {1}", AppContext.Current.ApplicationName, UtilHelper.GetResFileString("{SharedStrings:Mediachase_Commerce_Manager_5_0}")); Response.Cache.SetNoStore(); GetDefaultLink(); RegisterScripts(); ManagementHelper.RegisterBrowserStyles(this); }
public void ColumnResize(string ContextKey, int ColumnIndex, int NewSize) { EcfListViewContextKey key = UtilHelper.JsonDeserialize <EcfListViewContextKey>(ContextKey); try { // get old settings string gridSettingsKey = CMPageSettings.MakeGridSettingsKey(key.AppId, key.ViewId); string oldGridSettings = ProfileContext.Current.Profile.PageSettings.GetSettingString(gridSettingsKey); EcfListViewPreferences prefs = null; if (!String.IsNullOrEmpty(oldGridSettings)) { prefs = UtilHelper.JsonDeserialize <EcfListViewPreferences>(oldGridSettings); } if (prefs == null) { prefs = new EcfListViewPreferences(key.AppId, key.ViewId); } int index = ColumnIndex; AdminView view = ManagementContext.Current.FindView(key.AppId, key.ViewId); if (view != null && view.Columns.Count > ColumnIndex) { // get real index of a column with visibleIndex==ColumnIndex // start search from column with index == ColumnIndex because its visibleIndex<=ColumnIndex for (int i = ColumnIndex; i < view.Columns.Count; i++) { if (view.Columns[i].ColumnVisibleIndex == ColumnIndex) { index = i; break; } } } prefs.ColumnProperties[index.ToString()] = NewSize.ToString(); // save new settings ProfileContext.Current.Profile.PageSettings.SetSettingString(gridSettingsKey, UtilHelper.JsonSerialize(prefs)); ProfileContext.Current.Profile.Save(); } catch (Exception ex) { // TODO: handle exception } }
public async Task <IActionResult> Save([FromBody] ProductModel product, [FromServices] IHostingEnvironment host) { var result = new JsonData(); if (!string.IsNullOrEmpty(product.Img400)) { var file = new ProductImage { CreateTime = DateTime.Now, Name = Guid.NewGuid().ToString().ToLower(), Type = ImageType.Product, Length = Convert.FromBase64String(product.Img400.Replace("data:image/jpeg;base64,", "")).Length }; // 上传图片 var msg = await Service.UploadImageAsync(AppData.ApiUri + "/Product", Business.ID, file.Name + "." + file.ExtensionName, product.Img400, product.Img200, product.Img100); if (msg != "ok") { result.Msg = msg; return(Json(result)); } product.Images = new List <ProductImage> { file }; } // 图片上传成功后,保存商品 foreach (var item in product.Formats) { item.Code = Service.GetNextProductFormat(); } var entity = new Product { BusinessId = Business.ID, Description = product.Description, MinBuyQuantity = product.MinBuyQuantity, Name = product.Name, Pinyin = UtilHelper.GetPinyin(product.Name), FirstLetter = UtilHelper.GetFirstPinyin(product.Name), ProductTypeId = product.ProductTypeId, UnitName = product.UnitName, Scope = product.Scope, Images = product.Images, Formats = product.Formats, Attributes = product.Attributes, ProductIdSet = product.ProductIdSet, Feature = product.Feature, IsDiscount = product.IsDiscount }; Service.Add(entity); entity.Code = entity.ID.ToString().PadLeft(6, '0'); Service.Commit(); if (entity.Feature == ProductFeature.SetMeal && !string.IsNullOrEmpty(product.ProductIdSet)) { product.ProductIdSet.Split(',').ToList().ForEach(a => { var item = new ProductRelative { SetMealId = entity.ID, ProductId = Convert.ToInt32(a) }; Service.Add(item); }); } result.Success = true; result.Msg = "保存成功"; return(Ok(result)); }
public BusinessController(IBusinessRepository service, UtilHelper helper) { this.service = service; this.helper = helper; }
public static List <EventDetails> GetEventsList() { DateTime eventDate = DateTime.Now.AddHours(2); var retSource = new List <EventDetails> { new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1)), EventLocation = "AEC Offices", EventTitle = "Flight to Salt Lake city", EventId = 1, Status = "Declined", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "12345" } }; eventDate = eventDate.AddHours(2); retSource.Add(new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1.5)), EventLocation = "HDRF - Olaya street", EventTitle = "Team Meeting", EventId = 2, Status = "Accepted", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "13645" }); eventDate = eventDate.AddDays(1).AddHours(-2); retSource.Add(new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1)), EventLocation = "CBA Limited - Riyah, KSA", EventTitle = "Ford project Initialization", EventId = 3, Status = "Accepted", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "2" }); eventDate = eventDate.AddHours(3); retSource.Add(new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1)), EventLocation = "Google Office - Dubai", EventTitle = "Google Conference", EventId = 4, Status = "Accepted", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "3" }); eventDate = eventDate.AddDays(1).AddHours(3); retSource.Add(new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1)), EventLocation = "Excel centre - London UK", EventTitle = "Developers Conference", EventId = 5, Status = "Declined", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "4" }); eventDate = eventDate.AddDays(3); retSource.Add(new EventDetails { EventStart = UtilHelper.ConvertDateToSqlDate(eventDate), EventEnd = UtilHelper.ConvertDateToSqlDate(eventDate.AddHours(1)), EventLocation = "office abc - Riyah, KSA", EventTitle = "Client meetup", EventId = 6, Status = "Accepted", PhoneNumber = "01234567890", Email = "*****@*****.**", AdditionalInfo = "Dress code is required", JobPostId = "5" }); return(retSource); }
public override void Init() { slider = UtilHelper.Find <Slider>(transform, "Slider"); }
private void GetToolbarItemsFromXml(XPathNavigator node, List <McToolbarItem> itemsCollection) { foreach (XPathNavigator node1 in node.SelectChildren(string.Empty, string.Empty)) { McToolbarItem mcToolbarItem1 = new McToolbarItem(); switch (node1.Name) { case "Text": mcToolbarItem1.ItemType = McToolbarItemType.Text; break; case "Splitter": mcToolbarItem1.ItemType = McToolbarItemType.Splitter; break; case "Button": mcToolbarItem1.ItemType = McToolbarItemType.Button; break; case "Menu": mcToolbarItem1.ItemType = McToolbarItemType.Menu; break; case "SplitButton": mcToolbarItem1.ItemType = McToolbarItemType.SplitButton; break; default: throw new NotSupportedException(string.Format("Unknown nodeType: {0}", (object)node.Name)); } string attribute1 = node1.GetAttribute("id", string.Empty); string attribute2 = node1.GetAttribute("text", string.Empty); string attribute3 = node1.GetAttribute("imageUrl", string.Empty); string attribute4 = node1.GetAttribute("cssClass", string.Empty); string attribute5 = node1.GetAttribute("align", string.Empty); string attribute6 = node1.GetAttribute("handler", string.Empty); string attribute7 = node1.GetAttribute("commandName", string.Empty); string attribute8 = node1.GetAttribute("itemSplitter", string.Empty); string attribute9 = node1.GetAttribute("tooltip", string.Empty); string attribute10 = node1.GetAttribute("permissions", string.Empty); McToolbarItemAlign toolbarItemAlign = McToolbarItemAlign.Left; McToolbarItemSplitter toolbarItemSplitter = McToolbarItemSplitter.None; if (attribute5 != string.Empty) { try { toolbarItemAlign = (McToolbarItemAlign)Enum.Parse(typeof(McToolbarItemAlign), attribute5); } catch { throw; } } if (attribute8 != string.Empty) { try { toolbarItemSplitter = (McToolbarItemSplitter)Enum.Parse(typeof(McToolbarItemSplitter), attribute8); } catch { throw; } } mcToolbarItem1.Id = attribute1; mcToolbarItem1.Text = UtilHelper.GetResFileString(attribute2); if (attribute3 != string.Empty && (mcToolbarItem1.ItemType == McToolbarItemType.Button || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton || mcToolbarItem1.ItemType == McToolbarItemType.Menu)) { mcToolbarItem1.CssClass += "x-btn-wrap x-btn x-btn-text-icon "; } mcToolbarItem1.ImageUrl = this.ResolveClientUrl(attribute3); mcToolbarItem1.CssClass += attribute4; mcToolbarItem1.ItemAlign = toolbarItemAlign; mcToolbarItem1.Handler = attribute6; mcToolbarItem1.Tooltip = UtilHelper.GetResFileString(attribute9); CommandParameters cp = new CommandParameters(attribute7); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("GridId", this.GridId); dictionary.Add("GridClientId", this.GridClientId); dictionary.Add("permissions", attribute10); if (!string.IsNullOrEmpty(this.ContainerId)) { dictionary.Add("ContainerId", this.ContainerId); } cp.CommandArguments = dictionary; bool isEnabled = true; if (attribute7 != string.Empty) { string str = CommandManager.GetCurrent(this.Page).AddCommand(this.ClassName, this.ViewName, this.PlaceName, cp, out isEnabled); dictionary.Add("CommandManagerScript", str); cp.CommandArguments = dictionary; mcToolbarItem1.Params = cp.ToString(); mcToolbarItem1.Handler = "defaultToolbarOnClick"; } if (mcToolbarItem1.ItemType == McToolbarItemType.Menu || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton) { if (node1.SelectChildren(string.Empty, string.Empty).Count > 0) { this.GetToolbarItemsFromXml(node1, mcToolbarItem1.Items); if (mcToolbarItem1.Items.Count == 0) { continue; } } else { continue; } } if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Left)) { McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter); mcToolbarItem2.ItemAlign = toolbarItemAlign; itemsCollection.Add(mcToolbarItem2); } if (isEnabled) { itemsCollection.Add(mcToolbarItem1); } if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Right)) { McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter); mcToolbarItem2.ItemAlign = toolbarItemAlign; itemsCollection.Add(mcToolbarItem2); } } }
/// <summary> /// 电池片补片操作。 /// </summary> /// <remarks> /// 操作名称:<see cref="ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCH"/>。 /// </remarks> /// <param name="dsParams">包含补片信息的数据集对象。</param> /// <returns>包含结果数据的数据集对象。</returns> public DataSet LotPatch(DataSet dsParams) { DataSet dsReturn = new DataSet(); DbConnection dbConn = null; DbTransaction dbTran = null; try { dbConn = db.CreateConnection(); dbConn.Open(); dbTran = dbConn.BeginTransaction(); //参数数据。 if (dsParams == null || !dsParams.Tables.Contains(TRANS_TABLES.TABLE_PARAM) || //存放附加参数数据 !dsParams.Tables.Contains(WIP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME)) //存放操作数据 { ReturnMessageUtils.AddServerReturnMessage(dsReturn, "传入参数不正确,请检查。"); return(dsReturn); } DataTable dtParams = dsParams.Tables[TRANS_TABLES.TABLE_PARAM]; //存放附加参数数据 DataTable dtTransaction = dsParams.Tables[WIP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME]; //存放操作数据 Hashtable htTransaction = FanHai.Hemera.Share.Common.CommonUtils.ConvertToHashtable(dtTransaction); Hashtable htParams = FanHai.Hemera.Share.Common.CommonUtils.ConvertToHashtable(dtParams); string opEditTime = Convert.ToString(htParams[COMMON_FIELDS.FIELD_COMMON_EDIT_TIME]); //操作时编辑时间 string lotKey = Convert.ToString(htTransaction[WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY]); string editTimeZone = Convert.ToString(htTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY]); string editor = Convert.ToString(htTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDITOR]); double leftQty = Convert.ToDouble(htTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT]); string activity = Convert.ToString(htTransaction[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY]); //操作动作必须是 PATCH if (activity != ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCH) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, "传入参数的补片操作动作不正确,请检查。"); return(dsReturn); } //如果数据集中包含名称WIP_PATCH_FIELDS.DATABASE_TABLE_NAME的数据表对象。 if (dsParams.Tables.Contains(WIP_PATCH_FIELDS.DATABASE_TABLE_NAME)) { string transactionKey = UtilHelper.GenerateNewKey(0); string sql = string.Empty; double sumPatchedQty = 0; WIP_TRANSACTION_FIELDS wipFields = new WIP_TRANSACTION_FIELDS(); WIP_PATCH_FIELDS patchFields = new WIP_PATCH_FIELDS(); DataTable dtPatch = dsParams.Tables[WIP_PATCH_FIELDS.DATABASE_TABLE_NAME]; //存放补片明细数据 //遍历批次的报废数据。 for (int i = 0; i < dtPatch.Rows.Count; i++) { DataRow drPatch = dtPatch.Rows[i]; Hashtable htPatch = CommonUtils.ConvertRowToHashtable(drPatch); string patchedLotKey = Convert.ToString(htPatch[WIP_PATCH_FIELDS.FIELD_PATCHED_LOT_KEY]); double patchedQuantity = Convert.ToDouble(htPatch[WIP_PATCH_FIELDS.FIELD_PATCH_QUANTITY]); sumPatchedQty += patchedQuantity; //总的补片数量。 int isOnlyPatch = Convert.ToInt32(htPatch[WIP_PATCH_FIELDS.FIELD_IS_ONLY_PATCHED]); //获取被补片批次的信息 DataSet dsPatchLotInfo = LotManagement.GetLotBasicInfo(db, dbTran, patchedLotKey); DataRow drPatchLotInfo = dsPatchLotInfo.Tables[0].Rows[0]; double quantityIn = Convert.ToDouble(drPatchLotInfo[POR_LOT_FIELDS.FIELD_QUANTITY]); //isOnlyPatch=0 先报废后补片,所以数量不需要改变。isOnlyPatch=1 仅做补片。 double quantityOut = isOnlyPatch == 0? quantityIn: quantityIn + patchedQuantity; string enterpriseKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); string enterpriseName = Convert.ToString(drPatchLotInfo[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); string routeKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string routeName = Convert.ToString(drPatchLotInfo[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); string stepKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); string stepName = Convert.ToString(drPatchLotInfo[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); string workOrderKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY]); string stateFlag = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_STATE_FLAG]); string reworkFlag = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_IS_REWORKED]); string lineKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY]); string lineName = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_OPR_LINE]); string edcInsKey = Convert.ToString(drPatchLotInfo[POR_LOT_FIELDS.FIELD_EDC_INS_KEY]); string equipmentKey = Convert.ToString(drPatchLotInfo[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY]); string patchedTransactionKey = UtilHelper.GenerateNewKey(0); AddWIPLot(dbTran, patchedTransactionKey, patchedLotKey); //更新被补片批次的数量 sql = string.Format(@"UPDATE POR_LOT SET QUANTITY={0},EDITOR='{1}',EDIT_TIME=GETDATE(),EDIT_TIMEZONE='{2}' WHERE LOT_KEY='{3}'", quantityOut, editor.PreventSQLInjection(), editTimeZone.PreventSQLInjection(), patchedLotKey.PreventSQLInjection()); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); Hashtable htPatchedTransaction = new Hashtable(htTransaction); htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY] = patchedLotKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY] = enterpriseKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_NAME] = enterpriseName; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY] = routeKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ROUTE_NAME] = routeName; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY] = stepKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME] = stepName; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY] = workOrderKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_STATE_FLAG] = stateFlag; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG] = reworkFlag; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY] = lineKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE] = lineName; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE_PRE] = lineName; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDC_INS_KEY] = edcInsKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_EQUIPMENT_KEY] = equipmentKey; //插入报废记录。 //isOnlyPatch=0 先报废后补片。isOnlyPatch=1 仅做补片。 if (isOnlyPatch == 0) { string scrapTransaction = UtilHelper.GenerateNewKey(0); DataSet dsScrapParams = new DataSet(); htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN] = quantityIn; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT] = quantityIn - patchedQuantity; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY] = scrapTransaction; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY] = ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CELLSCRAP; DataTable dtScrapTransaction = CommonUtils.ParseToDataTable(htPatchedTransaction); dtScrapTransaction.TableName = WIP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME; dsScrapParams.Tables.Add(dtScrapTransaction); DataTable dtScrap = CommonUtils.CreateDataTable(new WIP_SCRAP_FIELDS()); DataRow drScrap = dtScrap.NewRow(); drScrap[WIP_SCRAP_FIELDS.FIELD_DESCRIPTION] = drPatch[WIP_PATCH_FIELDS.FIELD_DESCRIPTION]; drScrap[WIP_SCRAP_FIELDS.FIELD_EDIT_TIME] = drPatch[WIP_PATCH_FIELDS.FIELD_EDIT_TIME]; drScrap[WIP_SCRAP_FIELDS.FIELD_EDIT_TIMEZONE_KEY] = drPatch[WIP_PATCH_FIELDS.FIELD_EDIT_TIMEZONE_KEY]; drScrap[WIP_SCRAP_FIELDS.FIELD_EDITOR] = drPatch[WIP_PATCH_FIELDS.FIELD_EDITOR]; drScrap[WIP_SCRAP_FIELDS.FIELD_ENTERPRISE_KEY] = drPatch[WIP_PATCH_FIELDS.FIELD_ENTERPRISE_KEY]; drScrap[WIP_SCRAP_FIELDS.FIELD_ENTERPRISE_NAME] = drPatch[WIP_PATCH_FIELDS.FIELD_ENTERPRISE_NAME]; drScrap[WIP_SCRAP_FIELDS.FIELD_REASON_CODE_CLASS] = drPatch[WIP_PATCH_FIELDS.FIELD_REASON_CODE_CLASS]; drScrap[WIP_SCRAP_FIELDS.FIELD_REASON_CODE_KEY] = drPatch[WIP_PATCH_FIELDS.FIELD_REASON_CODE_KEY]; drScrap[WIP_SCRAP_FIELDS.FIELD_REASON_CODE_NAME] = drPatch[WIP_PATCH_FIELDS.FIELD_REASON_CODE_NAME]; drScrap[WIP_SCRAP_FIELDS.FIELD_RESPONSIBLE_PERSON] = drPatch[WIP_PATCH_FIELDS.FIELD_RESPONSIBLE_PERSON]; drScrap[WIP_SCRAP_FIELDS.FIELD_ROUTE_KEY] = drPatch[WIP_PATCH_FIELDS.FIELD_ROUTE_KEY]; drScrap[WIP_SCRAP_FIELDS.FIELD_ROUTE_NAME] = drPatch[WIP_PATCH_FIELDS.FIELD_ROUTE_NAME]; drScrap[WIP_SCRAP_FIELDS.FIELD_SCRAP_QUANTITY] = drPatch[WIP_PATCH_FIELDS.FIELD_PATCH_QUANTITY]; drScrap[WIP_SCRAP_FIELDS.FIELD_STEP_KEY] = drPatch[WIP_PATCH_FIELDS.FIELD_STEP_KEY]; drScrap[WIP_SCRAP_FIELDS.FIELD_STEP_NAME] = drPatch[WIP_PATCH_FIELDS.FIELD_STEP_NAME]; drScrap[WIP_SCRAP_FIELDS.FIELD_TRANSACTION_KEY] = scrapTransaction; dtScrap.Rows.Add(drScrap); dsScrapParams.Tables.Add(dtScrap); LotScrap(dsScrapParams, dbTran); } //插入被补片批次的操作记录 //isOnlyPatch=0 先报废后补片。isOnlyPatch=1 仅做补片。 if (isOnlyPatch == 0) { htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN] = quantityIn - patchedQuantity; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT] = quantityIn; } else { htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN] = quantityIn; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT] = quantityIn + patchedQuantity; } htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY] = patchedTransactionKey; htPatchedTransaction[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY] = ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCHED; sql = DatabaseTable.BuildInsertSqlStatement(wipFields, htPatchedTransaction, null); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //插入一笔批次补片明细数据 //补片操作记录主键。 if (!htPatch.ContainsKey(WIP_PATCH_FIELDS.FIELD_TRANSACTION_KEY)) { htPatch.Add(WIP_PATCH_FIELDS.FIELD_TRANSACTION_KEY, transactionKey); } htPatch[WIP_PATCH_FIELDS.FIELD_TRANSACTION_KEY] = transactionKey; //被补片批次操作记录主键 if (!htPatch.ContainsKey(WIP_PATCH_FIELDS.FIELD_PATCHED_TRANSACTION_KEY)) { htPatch.Add(WIP_PATCH_FIELDS.FIELD_PATCHED_TRANSACTION_KEY, patchedTransactionKey); } htPatch[WIP_PATCH_FIELDS.FIELD_PATCHED_TRANSACTION_KEY] = patchedTransactionKey; //重置补片明细的编辑时间为当前时间。 htPatch[WIP_PATCH_FIELDS.FIELD_EDIT_TIME] = null; sql = DatabaseTable.BuildInsertSqlStatement(patchFields, htPatch, null); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); } AddWIPLot(dbTran, transactionKey, lotKey); //获取组件补片批次当前数量 sql = string.Format("SELECT QUANTITY FROM POR_LOT WHERE LOT_KEY='{0}'", lotKey.PreventSQLInjection()); double quantity = Convert.ToDouble(db.ExecuteScalar(CommandType.Text, sql)); if (quantity < sumPatchedQty) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, string.Format("组件补片批次当前实际数量[{0}]小于补片数量[{1}],请确认。", quantity, sumPatchedQty)); dbTran.Rollback(); return(dsReturn); } //更新批次数量。 sql = string.Format(@"UPDATE POR_LOT SET QUANTITY={0},EDITOR='{1}',EDIT_TIME=GETDATE(),EDIT_TIMEZONE='{2}',DELETED_TERM_FLAG={3} WHERE LOT_KEY='{4}'", quantity - sumPatchedQty, editor.PreventSQLInjection(), editTimeZone.PreventSQLInjection(), (quantity - sumPatchedQty) > 0 ? 0 : 1, lotKey.PreventSQLInjection()); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); //向WIP_TRANSACTION表插入批次补片的操作记录。 if (!htTransaction.ContainsKey(WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY)) { htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY, transactionKey); } htTransaction[WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY] = transactionKey; sql = DatabaseTable.BuildInsertSqlStatement(wipFields, htTransaction, null); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); } dbTran.Commit(); ReturnMessageUtils.AddServerReturnMessage(dsReturn, string.Empty); } catch (Exception ex) { ReturnMessageUtils.AddServerReturnMessage(dsReturn, ex.Message); LogService.LogError("LotPatch Error: " + ex.Message); dbTran.Rollback(); } finally { dbConn.Close(); } return(dsReturn); }
public ActionResult SavePeople([Bind(Include = "Id,LastName,FirstName,BirthDate,PhotoPeople,ImageIsEmpty")] PeopleViewModel peopleModel) { bool saveCreateMode = (peopleModel.Id == 0) ? true : false; if (ModelState.IsValid) { try { // проверка на ввод Даты рождения (возраст от 5 до 150 лет) if (!UtilHelper.CheckBirthDate(peopleModel.BirthDate)) { ModelState.AddModelError("BirthDate", "Возраст может быть от 5 до 150 лет! Введите корректную дату рождения"); return(View("CreateEditPeople", peopleModel)); } // если изменяем запись if (!saveCreateMode && peopleModel.PhotoPeople == null) { // если фото было удалено пользователем if (peopleModel.ImageIsEmpty) { peopleModel.PhotoPeople = null; peopleModel.PhotoMIMEType = ""; } else { PeopleViewModel tmpPeopleModel = repository.GetPeople(peopleModel.Id); peopleModel.PhotoPeople = tmpPeopleModel.PhotoPeople; peopleModel.PhotoMIMEType = tmpPeopleModel.PhotoMIMEType; } } else { if (peopleModel.PhotoPeople != null && peopleModel.PhotoPeople.ContentLength > 0) { peopleModel.PhotoMIMEType = peopleModel.PhotoPeople.ContentType; } else { peopleModel.PhotoMIMEType = ""; } } repository.SavePeople(peopleModel); if (saveCreateMode) { Logger.logger.Info(String.Format("Добавлен человек:\n LastName={0}, FirstName={1}, BirthDate={2}", peopleModel.LastName, peopleModel.FirstName, peopleModel.BirthDateStr)); } else { Logger.logger.Info(String.Format("Изменен человек:\n Id={0}, LastName={1}, FirstName={2}, BirthDate={3}", peopleModel.Id, peopleModel.LastName, peopleModel.FirstName, peopleModel.BirthDateStr)); } return(RedirectToAction("Index")); } catch (Exception e) { Logger.LogException(e); } } else { return(View("CreateEditPeople", peopleModel)); } return(RedirectToAction("CreateEditPeople", peopleModel.Id)); }