Exemplo n.º 1
0
        public HttpResponseBase IlocUploadExcel()
        {
            string newName = string.Empty;
            string json = string.Empty;
            List<IlocQuery> store = new List<IlocQuery>();
            HashEncrypt hashpt = new HashEncrypt();
            try
            {

                DTIlocExcel.Clear();
                DTIlocExcel.Columns.Clear();
                DTIlocExcel.Columns.Add("料位編號", typeof(String));
                DTIlocExcel.Columns.Add("料位類型", typeof(String));
                DTIlocExcel.Columns.Add("所在層數");
                DTIlocExcel.Columns.Add("不能匯入的原因", typeof(String));
                int result = 0;
                int count = 0;//總匯入數
                int entercount = 0;//插入失敗個數
                int errorcount = 0;//數據異常個數
                int create_user = (Session["caller"] as Caller).user_id;
                if (Request.Files["ImportExcelFile"] != null && Request.Files["ImportExcelFile"].ContentLength > 0)
                {
                    HttpPostedFileBase excelFile = Request.Files["ImportExcelFile"];
                    newName = Server.MapPath(excelPath) + excelFile.FileName;
                    excelFile.SaveAs(newName);
                    DataTable dt = new DataTable();
                    NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newName);
                    dt = helper.SheetData();
                    if (dt.Rows.Count > 0)
                    {
                        _IlocMgr = new IlocMgr(mySqlConnectionString);
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);

                        int i = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
                            StringBuilder strsql = new StringBuilder();
                            Iloc ic = new BLL.gigade.Model.Iloc();
                            i++;
                            try
                            {
                                if (!string.IsNullOrEmpty(dr[0].ToString()) && Regex.IsMatch(dr[0].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$") && !string.IsNullOrEmpty(dr[1].ToString()) && (dr[1].ToString() == "S" || dr[1].ToString() == "R"))
                                {
                                    int loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[0].ToString());//判斷料位是否存在
                                    ic.loc_id = dr[0].ToString();
                                    ic.lsta_id = "F";
                                    ic.lcat_id = dr[1].ToString();
                                    ic.create_dtim = DateTime.Now;
                                    ic.change_dtim = DateTime.Now;
                                    ic.create_user = create_user;
                                    ic.change_user = create_user;
                                    ic.loc_status = 1;
                                    ic.lev = GetIntByString(dr[2].ToString());
                                    if (loc_id_exsit > 0)
                                    {
                                        DataRow drtwo = DTIlocExcel.NewRow();
                                        drtwo[0] = dr[0].ToString();
                                        drtwo[1] = dr[1].ToString();
                                        drtwo[2] = dr[2].ToString();
                                        drtwo[3] = "該料位已存在";
                                        DTIlocExcel.Rows.Add(drtwo);
                                        errorcount++;
                                        continue;
                                    }
                                    else//料位不存在
                                    {
                                        string has = hashpt.Md5Encrypt(ic.loc_id, "16");

                                        strsql.AppendFormat(@"insert into iloc(dc_id,whse_id,loc_id,llts_id,bkfill_loc,ldes_id,
                                             ldim_id,x_coord,y_coord,z_coord,bkfill_x_coord,bkfill_y_coord,
                                             bkfill_z_coord,lsta_id,sel_stk_pos,sel_seq_loc,sel_pos_hgt,rsv_stk_pos,
                                             rsv_pos_hgt,stk_lmt,stk_pos_wid,lev,lhnd_id,ldsp_id,
                                             create_user,create_dtim,comingle_allow,change_user,change_dtim,lcat_id,
                                             space_remain,max_loc_wgt,loc_status,stk_pos_dep,hash_loc_id
                    ) values ('{0}','{1}','{2}','{3}','{4}','{5}',
                              '{6}','{7}','{8}','{9}','{10}','{11}',
                              '{12}','{13}','{14}','{15}','{16}','{17}',
                              '{18}','{19}','{20}','{21}','{22}','{23}',
                              '{24}','{25}','{26}','{27}','{28}','{29}',
                              '{30}','{31}','{32}','{33}','{34}');",
                             ic.dc_id, ic.whse_id, ic.loc_id, ic.llts_id, ic.bkfill_loc, ic.ldes_id,
                             ic.ldim_id, ic.x_coord, ic.y_coord, ic.z_coord, ic.bkfill_x_coord, ic.bkfill_y_coord,
                             ic.bkfill_z_coord, ic.lsta_id, ic.sel_stk_pos, ic.sel_seq_loc, ic.sel_pos_hgt, ic.rsv_stk_pos,
                             ic.rsv_pos_hgt, ic.stk_lmt, ic.stk_pos_wid, ic.lev, ic.lhnd_id, ic.ldsp_id,
                             ic.create_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.create_dtim), ic.comingle_allow, ic.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.change_dtim), ic.lcat_id,
                             ic.space_remain, ic.max_loc_wgt, ic.loc_status, ic.stk_pos_dep, has
                             );
                                        result = _IlocMgr.SaveBySql(strsql.ToString());
                                        if (result > 0)
                                        {
                                            count++;
                                            continue;
                                        }
                                        else
                                        {
                                            DataRow drtwo = DTIlocExcel.NewRow();
                                            drtwo[0] = dr[0].ToString();
                                            drtwo[1] = dr[1].ToString();
                                            drtwo[2] = dr[2].ToString();
                                            drtwo[3] = "料位插入數據庫時失敗";
                                            DTIlocExcel.Rows.Add(drtwo);
                                            entercount++;
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    DataRow drtwo = DTIlocExcel.NewRow();
                                    drtwo[0] = dr[0].ToString();
                                    drtwo[1] = dr[1].ToString();
                                    drtwo[2] = dr[2].ToString();
                                    drtwo[3] = "料位編號或者料位類型或者所在層數不符合格式";
                                    DTIlocExcel.Rows.Add(drtwo);
                                    errorcount++;
                                    continue;
                                }
                            }
                            catch
                            {
                                DataRow drtwo = DTIlocExcel.NewRow();
                                drtwo[0] = dr[0].ToString();
                                drtwo[1] = dr[1].ToString();
                                drtwo[2] = dr[2].ToString();
                                drtwo[3] = "數據異常";
                                DTIlocExcel.Rows.Add(drtwo);
                                errorcount++;
                                continue;
                            }
                        }
                        if (count > 0)
                        {
                            json = "{success:true,total:" + count + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                        else
                        {
                            json = "{success:true,total:" + 0 + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                    }
                    else
                    {
                        json = "{success:true,total:" + 0 + ",error:" + 0 + ",entercount" + 0 + "}";
                    }
                }
            }
            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,data:" + "" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 2
0
        public HttpResponseBase HashAll()
        {
            string jsonStr = String.Empty;
            try
            {
                Iloc m = new Iloc();
                _IlocMgr = new IlocMgr(mySqlConnectionString);

                if (_IlocMgr.HashAll() > 0)
                {
                    jsonStr = "{success:true}";
                }
                else
                {
                    jsonStr = "{success:false}";
                }

            }
            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);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 3
0
 public void IlocExcelList()
 {
     string json = string.Empty;
     IlocQuery ilocQuery = new IlocQuery();
     DataTable dtExcel = new DataTable();
     try
     {
         ilocQuery.lcat_id = Request.Params["Ilocid_type"];
         if (!string.IsNullOrEmpty(Request.Params["search_type"]) && Request.Params["search_type"] != "null")//model中默認為F
         {
             ilocQuery.lsta_id = Request.Params["search_type"];
         }
         else
         {
             ilocQuery.lsta_id = string.Empty;
         }
         if (!string.IsNullOrEmpty(Request.Params["searchcontent"].Trim()))
         {
             ilocQuery.loc_id = Request.Params["searchcontent"].ToString().ToUpper();
         }
         DateTime time;
         if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
         {
             ilocQuery.starttime = time;
         }
         if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
         {
             ilocQuery.endtime = time;
         }
         List<IlocQuery> store = new List<IlocQuery>();
         _IlocMgr = new IlocMgr(mySqlConnectionString);
         store = _IlocMgr.GetIlocExportList(ilocQuery);
         dtExcel.Columns.Add("料位編號", typeof(String));
         dtExcel.Columns.Add("Hash料位", typeof(String));
         dtExcel.Columns.Add("修改人員", typeof(String));
         dtExcel.Columns.Add("修改時間", typeof(String));
         dtExcel.Columns.Add("料位類型", typeof(String));
         dtExcel.Columns.Add("料位狀態", typeof(String));
         for (int i = 0; i < store.Count; i++)
         {
             DataRow newRow = dtExcel.NewRow();
             newRow[0] = store[i].loc_id.ToString();
             newRow[1] = store[i].hash_loc_id.ToString();
             newRow[2] = store[i].change_users.ToString();
             newRow[3] = store[i].change_dtim.ToString();
             newRow[4] = store[i].lcat_id.ToString();
             newRow[5] = store[i].lsta_id.ToString();
             dtExcel.Rows.Add(newRow);
         }
         if (dtExcel.Rows.Count > 0)
         {
             string fileName = "料位維護_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
             MemoryStream ms = ExcelHelperXhf.ExportDT(dtExcel, "料位維護_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
             Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
             Response.BinaryWrite(ms.ToArray());
         }
         else
         {
             Response.Write("匯出數據不存在");
         }
     }
     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);
     }
 }
Exemplo n.º 4
0
        public void ExportIlocList()
        {
            string json = string.Empty;
            IlocQuery iloc = new IlocQuery();
            iloc.lcat_id = Request.Params["Ilocid_type"];
            if (!string.IsNullOrEmpty(Request.Params["startIloc"]))//model中默認為F
            {
                iloc.startiloc = Request.Params["startIloc"].ToUpper();
            }
            else
            {
                iloc.startiloc = string.Empty;
            }
            if (!string.IsNullOrEmpty(Request.Params["endIloc"]))
            {
                iloc.endiloc = Request.Params["endIloc"] + "Z";
                iloc.endiloc = iloc.endiloc.ToUpper();
            }
            else
            {
                iloc.endiloc = string.Empty;
            }

            if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
            }
            DataTable dtHZ = new DataTable();

            string newExcelName = string.Empty;
            dtHZ.Columns.Add("料位", typeof(String));
            dtHZ.Columns.Add("屬性", typeof(String));
            dtHZ.Columns.Add("狀態", typeof(String));
            dtHZ.Columns.Add("長", typeof(String));
            dtHZ.Columns.Add("寬", typeof(String));
            dtHZ.Columns.Add("主高", typeof(String));
            dtHZ.Columns.Add("副高", typeof(String));
            dtHZ.Columns.Add("類型", typeof(String));
            try
            {
                List<IlocQuery> store = new List<IlocQuery>();
                _IlocMgr = new IlocMgr(mySqlConnectionString);
                store = _IlocMgr.Export(iloc);

                foreach (var item in store)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = item.loc_id;
                    dr[1] = item.lcat_id;
                    dr[2] = item.lsta_id;

                    dr[3] = item.stk_pos_dep;
                    dr[4] = item.stk_pos_wid;

                    dr[5] = item.sel_pos_hgt;
                    dr[6] = item.rsv_pos_hgt;
                    dr[7] = item.ldes_id;
                    dtHZ.Rows.Add(dr);
                }
                if (System.IO.File.Exists(newExcelName))
                {
                    System.IO.File.Delete(newExcelName);
                }

                string fileName = "匯出可用主料位/副料位報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "匯出可用主料位/副料位報表_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(ms.ToArray());
            }
            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,data:[]}";
            }
        }
Exemplo n.º 5
0
        public HttpResponseBase DeleteLocid()
        {
            string jsonStr = String.Empty;
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            Iloc loc = new Iloc();
            try
            {
                string str = Request.Params["row_id"];//獲取類型
                str = str.Substring(0, str.LastIndexOf(","));
                loc.loc_id = str;//這個是row拼接的結果
                loc.change_dtim = DateTime.Now;
                loc.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                int j = _IlocMgr.DeleteLocidByIloc(loc); //更改iloc表中的狀態
                if (j > 0)
                {
                    jsonStr = "{success:true}";
                }
                else
                {
                    jsonStr = "{success:false}";
                }
            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 6
0
        public JsonResult UpdateIlocActive()
        {
            string jsonStr = string.Empty;
            try
            {
                _IlocMgr = new IlocMgr(mySqlConnectionString);
                Iloc loc = new Iloc();
                int id = Convert.ToInt32(Request.Params["id"]);
                string active = Request.Params["active"];
                if (active == "F")
                {
                    loc.lsta_id = "H";
                }
                else if (active == "H")
                {
                    loc.lsta_id = "F";
                }
                loc.row_id = id;
                loc.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                loc.change_dtim = DateTime.Now;

                if (_IlocMgr.UpdateIlocLock(loc) > 0)
                {
                    return Json(new { success = "true" });
                }
                else
                {
                    return Json(new { success = "false" });
                }
            }
            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);
                return Json(new { success = "false" });
            }
        }
Exemplo n.º 7
0
        public HttpResponseBase InestIloc()
        {
            string jsonStr = String.Empty;
            try
            {
                Iloc m = new Iloc();
                _IlocMgr = new IlocMgr(mySqlConnectionString);
                m.dc_id = Int32.Parse(Request.Params["dc_id"].ToString());
                m.whse_id = Int32.Parse(Request.Params["whse_id"].ToString());
                m.loc_id = Request.Params["loc_id"].ToString().ToUpper();
                m.llts_id = Request.Params["llts_id"].ToString();
                m.ldes_id = Request.Params["ldes_id"].ToString();
                m.lcat_id = Request.Params["lcat_id"];
                if (m.lcat_id == "S")//表示如果是主料位
                {
                    if (!string.IsNullOrEmpty(Request.Params["sel_stk_pos"]))
                    {
                        m.sel_stk_pos = Int32.Parse(Request.Params["sel_stk_pos"]);
                    }
                    else
                    {
                        m.sel_stk_pos = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["sel_pos_hgt"]))
                    {
                        m.sel_pos_hgt = Int32.Parse(Request.Params["sel_pos_hgt"]);
                    }
                    else
                    {
                        m.sel_pos_hgt = 0;
                    }
                    m.rsv_stk_pos = 0;
                    m.rsv_pos_hgt = 0;
                }
                else if (m.lcat_id == "R")//表示如果是副料位
                {
                    if (!string.IsNullOrEmpty(Request.Params["rsv_stk_pos"]))
                    {
                        m.rsv_stk_pos = Int32.Parse(Request.Params["rsv_stk_pos"]);
                    }
                    else
                    {
                        m.rsv_stk_pos = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["rsv_pos_hgt"]))
                    {
                        m.rsv_pos_hgt = Int32.Parse(Request.Params["rsv_pos_hgt"]);
                    }
                    else
                    {
                        m.rsv_pos_hgt = 0;
                    }
                    m.sel_stk_pos = 0;
                    m.sel_pos_hgt = 0;
                }
                m.loc_status = 1;
                m.stk_lmt = Int32.Parse(Request.Params["stk_lmt"]);
                m.stk_pos_wid = Int32.Parse(Request.Params["stk_pos_wid"]);
                m.lev = Int32.Parse(Request.Params["lev"]);
                m.lhnd_id = Request.Params["lhnd_id"];
                m.stk_pos_dep = Int32.Parse(Request.Params["stk_pos_dep"]);
                m.comingle_allow = Request.Params["comingle_allow"];
                //m.ldsp_id = Request.Params["ldsp_id"];
                m.ldsp_id = string.Empty;
                if (String.IsNullOrEmpty(Request.Params["row_id"]))
                {
                    m.create_dtim = DateTime.Now;       //創建時間
                    m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    m.change_dtim = DateTime.Now;   //編輯時間
                    m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;

                    if (_IlocMgr.IlocInsert(m) > 0)
                    {
                        jsonStr = "{success:true}";
                    }
                    else
                    {
                        jsonStr = "{success:false}";
                    }
                }
                else
                {
                    m.row_id = Convert.ToInt32(Request.Params["row_id"]);
                    m.change_dtim = DateTime.Now;
                    m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    if (_IlocMgr.IlocEdit(m) > 0)
                    {
                        jsonStr = "{success:true,msg:0}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:0}";//返回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);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 8
0
        // 判斷料號是否重複
        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;
        }
Exemplo n.º 9
0
 public HttpResponseBase GetIlocList()
 {
     string json = string.Empty;
     IlocQuery iloc = new IlocQuery();
     iloc.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
     iloc.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
     iloc.lcat_id = Request.Params["Ilocid_type"];
     if (!string.IsNullOrEmpty(Request.Params["search_type"]))//model中默認為F
     {
         iloc.lsta_id = Request.Params["search_type"];
     }
     else
     {
         iloc.lsta_id = string.Empty;
     }
     if (!string.IsNullOrEmpty(Request.Params["searchcontent"].Trim()))
     {
         iloc.loc_id = Request.Params["searchcontent"].ToString().ToUpper();
     }
     DateTime time;
     if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
     {
         iloc.starttime = time;
     }
     if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
     {
         iloc.endtime = time;
     }
     try
     {
         List<IlocQuery> store = new List<IlocQuery>();
         _IlocMgr = new IlocMgr(mySqlConnectionString);
         int totalCount = 0;
         store = _IlocMgr.GetIocList(iloc, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回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;
 }
Exemplo n.º 10
0
        public HttpResponseBase SavePallet()
        {
            string json = string.Empty;
            string result = string.Empty;
            int userId = (Session["caller"] as Caller).user_id;
            try
            {
                string arr = Request.Params["num"];
                IinvdQuery Iinvd = new IinvdQuery();
                _IlocMgr = new IlocMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["prod_id"]))//查詢商品编号
                {
                    if (Request.Params["prod_id"].Length == 6)
                    {
                        Iinvd.item_id = uint.Parse(Request.Params["prod_id"]);
                    }
                    else
                    {
                        Iinvd.upc_id = Request.Params["prod_id"];
                    }

                    if (!string.IsNullOrEmpty(Request.Params["sloc_id"]))
                    {
                        if (Request.Params["sloc_id"].Trim().Length > 8)//大於8表示不是正常的料位,判斷是否為hash料位
                        {
                            Iinvd.plas_loc_id = _IlocMgr.GetLocidByHash(Request.Params["sloc_id"].Trim().ToUpper());
                        }
                        else
                        {
                            Iinvd.plas_loc_id = Request.Params["sloc_id"].ToString().Trim().ToUpper();
                        }
                    }
                }
                string eloc_id = string.Empty;
                if (Request.Params["eloc_id"].Trim().ToUpper().Length > 8)
                {
                    eloc_id = _IlocMgr.GetLocidByHash(Request.Params["eloc_id"].Trim().ToUpper());
                }
                else
                {
                    eloc_id = Request.Params["eloc_id"].Trim().ToUpper();
                }

                //int[] num = Array.ConvertAll<string, int>(nums, delegate(string s) { return int.Parse(s); });
                _ipalet = new PalletMoveMgr(mySqlConnectionString);
                result = _ipalet.UpPallet(Iinvd, eloc_id, arr, userId);
                json = "{success:true,msg:\"" + result + "\"}";
            }
            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,msg:\"" + result + "\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 11
0
        public HttpResponseBase InsertIinvd()
        {
            string jsonStr = String.Empty;
            Int64 aaa = 0;  //無用變數
            uint p = 0;  //無用變數
            try
            {
                Iinvd m = new Iinvd();
                IialgQuery ia = new IialgQuery();
                Iupc iu = new Iupc();
                ProductItem proitem = new ProductItem();
                Caller call = new Caller();
                IstockChangeQuery stock = new IstockChangeQuery();
                call = (System.Web.HttpContext.Current.Session["caller"] as Caller);
                string path = "";
                _iinvd = new IinvdMgr(mySqlConnectionString);
                _iagMgr = new IialgMgr(mySqlConnectionString);
                _IiupcMgr = new IupcMgr(mySqlConnectionString);
                #region 獲取數據往
                if (Int64.TryParse(Request.Params["item_id"].ToString(), out aaa))
                {
                    if (uint.TryParse(Request.Params["item_id"].ToString(), out p))
                    {
                        m.item_id = uint.Parse(Request.Params["item_id"].ToString());
                    }
                    if (Request.Params["item_id"].ToString().Length > 6)
                    {
                        m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString());
                    }
                }
                else
                {
                    if (Request.Params["item_id"].ToString().Length > 6)
                    {
                        m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString());
                    }
                }

                m.dc_id = 1;
                m.whse_id = 1;
                m.prod_qty = Int32.Parse(Request.Params["prod_qty"].ToString());//數量
                DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                DateTime dtime;
                if (DateTime.TryParse(Request.Params["startTime"].ToString(), out dtime))
                {//用戶填寫創建時間算出有效日期
                    DateTime start = DateTime.Parse(Request.Params["startTime"].ToString());
                    m.made_date = start;
                    if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p))
                    {
                        m.cde_dt = start.AddDays(Int32.Parse(Request.Params["cde_dt_incr"].ToString()));
                    }
                    else
                    {
                        m.cde_dt = DateTime.Now;
                    }
                }
                else
                {
                    if (DateTime.TryParse(Request.Params["cde_dt"].ToString(), out dtime))
                    {//用戶填寫有效日期算出製造日期
                        m.cde_dt = DateTime.Parse(Request.Params["cde_dt"].ToString());//有效時間 
                        if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p))
                        {
                            m.made_date = m.cde_dt.AddDays(-Int32.Parse(Request.Params["cde_dt_incr"].ToString()));
                        }
                        else
                        {
                            m.made_date = today;
                        }
                    }
                    else
                    {
                        m.cde_dt = today;
                        m.made_date = today;
                    }
                }
                m.cde_dt = DateTime.Parse(m.cde_dt.ToShortDateString());
                m.made_date = DateTime.Parse(m.made_date.ToShortDateString());
                m.plas_loc_id = Request.Params["plas_loc_id"].ToString().ToUpper();//上架料位
                string loc_id = Request.Params["loc_id"].ToString().ToUpper();
                m.change_dtim = DateTime.Now;//編輯時間
                m.receipt_dtim = DateTime.Now;//收貨時間
                m.create_user = (Session["caller"] as Caller).user_id;
                #endregion
                #region 獲取數據添加打iialg
                ia.loc_id = m.plas_loc_id.ToString().ToUpper();
                ia.item_id = m.item_id;
                stock.sc_trans_type = 0;
                if (!string.IsNullOrEmpty(Request.Params["iarc_id"].ToString()))
                {
                    ia.iarc_id = Request.Params["iarc_id"].ToString();
                }
                else
                {
                    ia.iarc_id = "PC";
                    stock.sc_trans_type = 1;//收貨上架
                }
                //if (ia.iarc_id == "DR" || ia.iarc_id == "KR")
                //{
                //    type = 2;//RF理貨
                //}

                ia.create_dtim = DateTime.Now;
                ia.create_user = m.create_user;
                ia.doc_no = "P" + DateTime.Now.ToString("yyyyMMddHHmmss");
                if (!string.IsNullOrEmpty(Request.Params["doc_num"]))
                {
                    ia.doc_no = Request.Params["doc_num"];
                    stock.sc_trans_id = ia.doc_no;//交易單號
                }
                if (!string.IsNullOrEmpty(Request.Params["Po_num"]))
                {
                    ia.po_id = Request.Params["Po_num"];
                    stock.sc_cd_id = ia.po_id;//前置單號
                }
                if (!string.IsNullOrEmpty(Request.Params["remark"]))
                {
                    ia.remarks = Request.Params["remark"];
                    stock.sc_note = ia.remarks;//備註 
                }
                ia.made_dt = m.made_date;
                ia.cde_dt = m.cde_dt;
                #endregion

                #region 獲取店內條碼-=添加條碼

                if (!string.IsNullOrEmpty(Request.Params["vendor_id"].ToString()))
                {
                    iu.upc_id = CommonFunction.GetUpc(m.item_id.ToString(), Request.Params["vendor_id"].ToString(), m.cde_dt.ToString("yyMMdd"));
                }
                iu.item_id = m.item_id;
                iu.upc_type_flg = "2";//店內碼
                iu.create_user = m.create_user;
                string result = _IiupcMgr.IsExist(iu);//是否有重複的條碼
                if (result == "0")
                {
                    if (_IiupcMgr.Insert(iu) < 1)
                    {
                        jsonStr = "{success:true,msg:2}";
                    }
                }
                #endregion

                #region 新增/編輯
                #region 庫存調整的時候,商品庫存也要調整
                _proditemMgr = new ProductItemMgr(mySqlConnectionString);
                int item_stock = m.prod_qty;
                proitem.Item_Stock = item_stock;
                proitem.Item_Id = m.item_id;
                #endregion
                if (_iinvd.IsUpd(m, stock) > 0)
                {//編輯             
                    ia.qty_o = _iinvd.Selnum(m);
                    ia.adj_qty = m.prod_qty;

                    m.prod_qty = ia.qty_o + m.prod_qty;
                    if (m.prod_qty >= 0)
                    {
                        if (_iinvd.Upd(m) > 0)
                        {
                            if (Request.Params["iialg"].ToString() == "Y")
                            {// 
                                if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改
                                {
                                    path = "/WareHouse/KutiaoAddorReduce";
                                    _proditemMgr.UpdateItemStock(proitem, path, call);
                                }
                                if (_iagMgr.insertiialg(ia) > 0)
                                {
                                    jsonStr = "{success:true,msg:0}";//更新成功
                                }
                                else
                                {
                                    jsonStr = "{success:false,msg:1}";//更新失敗
                                }
                            }
                            else
                            {
                                jsonStr = "{success:true,msg:0}";//更新成功
                            }
                        }
                        else
                        {
                            jsonStr = "{success:false,msg:1}";//更新失敗
                        }
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:1}";//庫存為負數
                    }
                }
                else
                {//新增
                    m.ista_id = "A";
                    m.create_dtim = DateTime.Now;       //創建時間
                    if (_iinvd.Insert(m) > 0)
                    {
                        _IlocMgr = new IlocMgr(mySqlConnectionString);
                        Iloc loc = new BLL.gigade.Model.Iloc();
                        loc.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                        loc.change_dtim = DateTime.Now;
                        loc.loc_id = m.plas_loc_id.ToString().ToUpper();
                        if (loc_id.Trim() != m.plas_loc_id.Trim())//判斷如果是主料位不需要進行多餘的操作
                        {
                            if (_IlocMgr.SetIlocUsed(loc) > 0)
                            {
                                if (Request.Params["iialg"].ToString() == "Y")
                                {
                                    if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改
                                    {
                                        path = "/WareHouse/KutiaoAddorReduce";
                                        _proditemMgr.UpdateItemStock(proitem, path, call);
                                    }
                                    ia.qty_o = 0;
                                    ia.adj_qty = m.prod_qty;
                                    if (_iagMgr.insertiialg(ia) > 0)
                                    {
                                        jsonStr = "{success:true,msg:0}";//更新成功
                                    }
                                    else
                                    {
                                        jsonStr = "{success:false,msg:1}";//更新失敗
                                    }
                                }
                                else
                                {
                                    jsonStr = "{success:true,msg:0}";//新增成功
                                }
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:1}";//新增失敗
                            }
                        }
                        else
                        {
                            if (Request.Params["iialg"].ToString() == "Y")
                            {
                                if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改
                                {
                                    path = "/WareHouse/KutiaoAddorReduce";
                                    _proditemMgr.UpdateItemStock(proitem, path, call);
                                }
                                ia.qty_o = 0;
                                ia.adj_qty = m.prod_qty;
                                if (_iagMgr.insertiialg(ia) > 0)
                                {
                                    jsonStr = "{success:true,msg:0}";//更新成功
                                }
                                else
                                {
                                    jsonStr = "{success:false,msg:1}";//更新失敗
                                }
                            }
                            else
                            {
                                jsonStr = "{success:true,msg:0}";//新增成功
                            }
                        }
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:1}";
                    }
                }
                #endregion
            }
            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);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 12
0
        //刪除沒有商品佔據的主料位
        public HttpResponseBase DeleteIplasById()
        {
            string jsonStr = String.Empty;
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            Iloc loc = new Iloc();
            IplasQuery plasQuery = new IplasQuery();
            IinvdQuery nvdQery = new IinvdQuery();
            try
            {
                string str = Request.Params["loc_id"].ToString().ToUpper();//獲取類型
                str = str.Substring(0, str.LastIndexOf(","));
                int sum = 0;
                string[] strs = str.Split(',');
                for (int i = 0; i < strs.Length; i++)
                {
                    nvdQery.loc_id = strs[i];
                    sum = sum + _IiplasMgr.GetIinvdItemId(nvdQery);
                }
                if (sum > 0)
                {
                    jsonStr = "{success:true,sum:" + sum + "}";//大於0表示算選包含庫存量
                }
                else
                {
                    int counts = 0;
                    for (int i = 0; i < strs.Length; i++)
                    {
                        plasQuery.loc_id = strs[i];
                        counts = counts + _IiplasMgr.DeleteIplasById(plasQuery);
                    }

                    if (counts > 0)
                    {
                        jsonStr = "{success:true,count:" + counts + "}";
                    }
                    else
                    {
                        jsonStr = "{success:false}";
                    }
                }
            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 13
0
        public HttpResponseBase GetIPlasEdit()
        {
            string json = string.Empty;
            IplasQuery iplas = new IplasQuery();
            Iloc iloc = new Iloc();
            Iupc upc = new Iupc();
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            _ipalet = new PalletMoveMgr(mySqlConnectionString);
            try
            {
                if (string.IsNullOrEmpty(Request.Params["plas_id"]))//首先考慮添加情況
                {
                    string itemid = Request.Params["item_id"];
                    DataTable dt = _ipalet.GetProdInfo(itemid);
                    if (dt.Rows.Count > 0)
                    {
                        iplas.item_id = uint.Parse(dt.Rows[0]["item_id"].ToString());
                    }
                    else
                    {
                        iplas.item_id = 0;
                    }
                    if (_IiplasMgr.IsTrue(iplas) == "false")
                    {
                        json = "{success:false,msg:\"" + "商品編號不存在" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    if (_IiplasMgr.GetIplasid(iplas) > 0)
                    {
                        json = "{success:false,msg:\"" + "此商品已存在主料位" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    iloc.loc_id = Request.Params["loc_id"].ToString().ToUpper();
                    if (_IiplasMgr.GetLocCount(iloc) <= 0)
                    {
                        json = "{success:false,msg:\"" + "非主料位或主料位已鎖定" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    iplas.loc_id = Request.Params["loc_id"].ToString().ToUpper();
                    if (_IiplasMgr.GetIplasCount(iplas).Count > 0)//主料位重複
                    {
                        json = "{success:false,msg:\"" + "主料位重複" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    iplas.loc_stor_cse_cap = int.Parse(Request.Params["loc_stor_cse_cap"]);
                    iplas.create_user = (Session["caller"] as Caller).user_id;
                    iplas.create_dtim = DateTime.Now;
                    iplas.change_user = (Session["caller"] as Caller).user_id;
                    iplas.change_dtim = DateTime.Now;
                    _IiplasMgr.InsertIplas(iplas);//判斷主料位和商品編號沒有問題,插入Iplas表的同時.操作iloc表,設置其為已指派料位
                    json = "{success:true}";
                }
                else//編輯
                {
                    iplas.plas_id = int.Parse(Request.Params["plas_id"]);
                    upc.upc_id = Request.Params["upcid"];
                    iplas.item_id = uint.Parse(Request.Params["item_id"]);
                    iplas.loc_id = Request.Params["loc_id"].ToString().ToUpper();
                    iloc.loc_id = iplas.loc_id;
                    if (_IiplasMgr.GetLocCount(iloc) <= 0)
                    {
                        json = "{success:false,msg:\"" + "非主料位或主料位已鎖定" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    if (_IiplasMgr.GetIplasCount(iplas).Count > 0)//主料位重複
                    {
                        json = "{success:false,msg:\"" + "該主料位不可用!" + "\"}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                    iplas.loc_stor_cse_cap = int.Parse(Request.Params["loc_stor_cse_cap"]);
                    iplas.change_user = (Session["caller"] as Caller).user_id;
                    iplas.change_dtim = DateTime.Now;
                    _IiplasMgr.UpIplas(iplas);
                    json = "{success:true}";
                }
            }
            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}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 14
0
 public JsonResult GetIlocCount()
 {
     string result = "false";
     try
     {
         IlocQuery query = new IlocQuery();
         query.loc_id = Request.Params["loc_id"].ToUpper();
         List<IlocQuery> ilocList = new List<IlocQuery>();
         _IlocMgr = new IlocMgr(mySqlConnectionString);
         if (_IlocMgr.GetIlocCount(query)!="")
         {                    
                 result = "true";
         }
         else
         {
             result = "false";
         }
     }
     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);
     }
     return Json(new { success = result });
 }
Exemplo n.º 15
0
        public ActionResult IinvdCheck()
        {
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            StringBuilder strHtml = new StringBuilder();
            string loc_id = Request.Params["loc_id"];
            IlocQuery ilocquery=new IlocQuery();
            ilocquery.loc_id = loc_id;
            loc_id = _IlocMgr.GetIlocCount(ilocquery);
            ViewBag.loc_id = loc_id;
            ViewBag.lcat_id = "";
            ViewBag.upc_id = "";
            ViewBag.iplas = "";
            _iinvd = new IinvdMgr(mySqlConnectionString);
            if (loc_id != "")
            {
                List<IinvdQuery> list = _iinvd.GetIinvdList(loc_id);
                IupcQuery iupc = new IupcQuery();
                _IiupcMgr = new IupcMgr(mySqlConnectionString);
                if (list.Count > 0)
                {
                    ViewBag.product_name = list[0].product_name;
                    ViewBag.spec = list[0].spec;
                    ViewBag.item_id = list[0].item_id.ToString()                                        ;
                    ViewBag.pwy_dte_ctl = list[0].pwy_dte_ctl;
                    iupc.item_id=uint.Parse(ViewBag.item_id);
                    List<IupcQuery> listiupc=new List<IupcQuery>();
                    if (iupc.item_id!=0)
                    {
                        listiupc = _IiupcMgr.GetIupcByItemID(iupc);
                    }
                    if (listiupc.Count > 0)
                    {
                        ViewBag.upc_id = listiupc[0].upc_id;
                    }

                    if (list[0].pwy_dte_ctl == "Y")
                    {
                        ViewBag.count = list.Count;
                    }
                    else
                    {
                        int prod_qty = 0;
                        for (int i = 0; i < list.Count; i++)
                        {
                            prod_qty += list[i].prod_qty;
                        }
                        list[0].prod_qty = prod_qty;
                        ViewBag.count = 1;
                    }
                    ViewBag.data = list;

                    IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id);
                    Iloc iloc = new Iloc();
                    if (lsta_id != null)
                    {
                        if (lsta_id.lsta_id == "F")
                        {
                            iloc.row_id = lsta_id.row_id;
                            iloc.lsta_id = "A";
                            iloc.change_dtim = DateTime.Now;
                            iloc.change_user = (Session["caller"] as Caller).user_id;
                            _IlocMgr.UpdateIlocLock(iloc);
                        }
                    } 
                }
                else {
                    ViewBag.product_name ="";
                    ViewBag.spec = "";
                    ViewBag.item_id = "此料位暫無商品";
                    IinvdQuery iinvd = new IinvdQuery();
                    iinvd.prod_qty = 0;
                    list.Add(iinvd);
                    ViewBag.pwy_dte_ctl = Request.Params["pwy_dte_ctl"]; ;
                    ViewBag.count = 0;
                    ViewBag.data = list;

                    IIlocImplMgr ilocMgr = new IlocMgr(mySqlConnectionString);
                    IplasDao iplas = new IplasDao(mySqlConnectionString);
                    int total = 0;
                    ilocquery.loc_id = loc_id;
                    ilocquery.lcat_id = "0";
                    ilocquery.lsta_id = "";
                    ilocquery.IsPage = false;
                    List<IlocQuery> listiloc = ilocMgr.GetIocList(ilocquery, out total);
                    if (listiloc.Count > 0)
                    {
                        string lcat_id =listiloc.Count==0?"": listiloc[0].lcat_id;
                        if (lcat_id == "S")
                        {
                            string item_id = iplas.Getlocid(loc_id);
                            if (item_id != "")
                            {
                                ViewBag.item_id = item_id;
                                iupc.item_id = uint.Parse(ViewBag.item_id);
                                List<IupcQuery> listiupc = _IiupcMgr.GetIupcByItemID(iupc);
                                if (listiupc.Count > 0)
                                {
                                    ViewBag.upc_id = listiupc[0].upc_id;
                                }
                                DataTable table = iplas.GetProduct(item_id);
                                if (table.Rows.Count > 0)
                                {
                                    ViewBag.product_name = table.Rows[0]["product_name"];
                                    ViewBag.spec = table.Rows[0]["spec"];
                                    ViewBag.lcat_id = lcat_id;
                                }
                                DataTable tablePwy = _iinvd.Getprodubybar(item_id);
                                if (tablePwy.Rows.Count > 0)
                                {
                                    ViewBag.pwy_dte_ctl = tablePwy.Rows[0]["pwy_dte_ctl"].ToString();
                                }
                            }
                            else
                            {
                                IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id);
                                Iloc iloc = new Iloc();
                                if (lsta_id != null)
                                {
                                    if (lsta_id.lsta_id != "H")
                                    {
                                        iloc.row_id = lsta_id.row_id;
                                        iloc.lsta_id = "F";
                                        iloc.change_dtim = DateTime.Now;
                                        iloc.change_user = (Session["caller"] as Caller).user_id;
                                        _IlocMgr.UpdateIlocLock(iloc);
                                    }
                                } 
                                ViewBag.iplas = "false";
                                ViewBag.pwy_dte_ctl = "N";
                            }
                        }
                        else {
                            IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id);
                            Iloc iloc = new Iloc();
                            if(lsta_id!=null)
                            {
                                if(lsta_id.lsta_id!="H")
                                {
                                    iloc.row_id=lsta_id.row_id;
                                    iloc.lsta_id = "F";
                                    iloc.change_dtim = DateTime.Now;
                                    iloc.change_user = (Session["caller"] as Caller).user_id;
                                    _IlocMgr.UpdateIlocLock(iloc);
                                }
                            }
                            ViewBag.pwy_dte_ctl = "N";
                        }
                    }
                }
                if (ViewBag.pwy_dte_ctl==null)
                {
                    ViewBag.pwy_dte_ctl = "";
                }
            }
            return View();
        }