// 判斷料號是否重複 public HttpResponseBase GetLoc_id() { string json = string.Empty; Iloc loc = new Iloc(); int result = 0; try { _IlocMgr = new IlocMgr(mySqlConnectionString); if (String.IsNullOrEmpty(Request.Params["row_id"]))//如果是新增 { loc.loc_id = Request.Params["id"].ToString().ToUpper(); result = _IlocMgr.GetLoc_id(loc); } else { loc.loc_id = Request.Params["id"].ToUpper(); int row_id = Convert.ToInt32(Request.Params["row_id"]); string loc_id = _IlocMgr.GetLoc_idByRow_id(row_id); if (loc_id == loc.loc_id) { result = 0;//當編輯沒有改變時,則表示此料位沒有重複 } else { result = _IlocMgr.GetLoc_id(loc); } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,data:" + result + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }