Exemplo n.º 1
0
        //獲取製造日期,有效日期判斷是否日期控管
        public HttpResponseBase JudgeDate()
        {
            string jsonStr = "{success:false}";
            DateTime dt = new DateTime();
            DataTable data = new DataTable();
            _iinvd = new IinvdMgr(mySqlConnectionString);
            int day = 0;
            try
            {
                string dtstring = Request.Params["dtstring"].ToString();
                if (DateTime.TryParse(Request.Params["startTime"].ToString(), out dt))
                {
                    #region 編號獲取數據
                    if (!int.TryParse(Request.Params["item_id"].ToString(), out day))
                    {//獲取條碼
                        data = _iinvd.Getprodubybar(Request.Params["item_id"].ToString());
                    }
                    else
                    {//獲取商品編號
                        data = _iinvd.Getprodu(int.Parse(Request.Params["item_id"].ToString()));
                    }
                    #endregion
                    DateTime dts = DateTime.Parse(Request.Params["startTime"].ToString());

                    if (data.Rows.Count > 0)
                    {//該商品有數據才往下進行
                        if (data.Rows[0]["pwy_dte_ctl"].ToString() == "Y")
                        {//需要日期控管才進行操作]
                            DateTime dte = dts, dtss, dtee;
                            dt = DateTime.Now;
                            if (dtstring == "1" || dtstring == "2")
                            {
                                if (dtstring == "1")
                                {//根據製造日期求出有效期
                                    dte = dts.AddDays(int.Parse(data.Rows[0]["cde_dt_incr"].ToString()));//製造日期+保質期=有效期
                                }
                                if (dtstring == "2")
                                {//根據有效日期求出製造日期
                                    dts = dte.AddDays(-int.Parse(data.Rows[0]["cde_dt_incr"].ToString()));
                                }
                                //
                                if (dts > dt)
                                {
                                    jsonStr = "{success:true,msg:'1'}";
                                }
                                else
                                {
                                    dtss = dts.AddDays(int.Parse(data.Rows[0]["cde_dt_var"].ToString()));//製造時間+允出天數
                                    dtee = dt.AddDays(int.Parse(data.Rows[0]["cde_dt_shp"].ToString()));//今天+允出天數
                                    if (dt > dtss)
                                    {
                                        jsonStr = "{success:true,msg:'2'}";
                                        if (dtee > dte)
                                        {
                                            jsonStr = "{success:true,msg:'3'}";
                                            if (dte < dt)
                                            {
                                                jsonStr = "{success:true,msg:'4',dte:'" + dte.ToShortDateString() + "'}";
                                            }
                                        }
                                    }
                                    else
                                    { //有效期匯出                                       
                                        jsonStr = "{success:true,msg:'5',dts:'" + dts.ToString("yyyy-MM-dd") + "',dte:'" + dte.ToString("yyyy-MM-dd") + "'}";
                                    }
                                }
                            }
                            else
                            {
                                jsonStr = "{success:false}";
                            }
                        }
                        else
                        {
                            if (dts > DateTime.Now)
                            {
                                jsonStr = "{success:true,msg:'1'}";
                            }
                        }
                    }
                    else
                    {
                        if (dts > DateTime.Now)
                        {
                            jsonStr = "{success:true,msg:'1'}";
                        }
                    }
                }
            }
            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.º 2
0
        public void ExportKucunLockList()
        {
            string json = string.Empty;
            IinvdQuery m = new IinvdQuery();
            if (!string.IsNullOrEmpty(Request.Params["startIloc"]))
            {//料位開始
                m.startIloc = Request.Params["startIloc"].ToUpper();
            }
            if (!string.IsNullOrEmpty(Request.Params["endIloc"]))
            {
                m.endIloc = Request.Params["endIloc"] + "Z";
                m.endIloc = m.endIloc.ToUpper();
            }
            _iinvd = new IinvdMgr(mySqlConnectionString);
            if (!String.IsNullOrEmpty(Request.Params["item_id"]))//料位和條碼不再通過長度來判斷了
            {
                ////if (Request.Params["item_id"].ToString().Length >= 8)
                ////{
                    DataTable dt = new DataTable();
                    dt = _iinvd.Getprodubybar(Request.Params["item_id"].ToString());
                    if (dt.Rows.Count > 0)
                    {
                        m.item_id = Convert.ToUInt32(dt.Rows[0]["item_id"].ToString());
                    }
                ////}
                    else
                    {
                        int itemid = 0;
                    }

                //m.upc_id
            }
            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("有效期/FIFO", typeof(String));
            dtHZ.Columns.Add("是否買斷", typeof(String));
            dtHZ.Columns.Add("條碼", typeof(String));
            dtHZ.Columns.Add("庫鎖原因", typeof(String));
            dtHZ.Columns.Add("庫鎖備註", typeof(String));
            try
            {
                List<IinvdQuery> store = new List<IinvdQuery>();
                _iinvd = new IinvdMgr(mySqlConnectionString);
                _IiupcMgr = new IupcMgr(mySqlConnectionString);
                store = _iinvd.KucunExport(m);
                foreach (var item in store)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = item.plas_loc_id;
                    dr[1] = item.prod_qty;
                    dr[2] = item.item_id;
                    dr[3] = item.product_name;
                    dr[4] = GetProductSpec(item.item_id.ToString());
                    dr[5] = item.cde_dt.ToString("yyyy-MM-dd");
                    dr[6] = item.prepaid == 0 ? "否" : "是";
                    dr[7] = " " + _IiupcMgr.Getupc(item.item_id.ToString(), "0");
                    dr[8] = item.parameterName;
                    m.item_id = uint.Parse(item.item_id.ToString());
                    m.plas_loc_id = item.plas_loc_id.ToString();
                    m.made_date = item.made_date;
                    if (item.ista_id.ToString() == "H")
                    {
                        dr[9] = _iinvd.remark(m);
                    }
                    else
                    {
                        dr[9] = "";
                    }
                    dtHZ.Rows.Add(dr);
                }
                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.º 3
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.º 4
0
        // 用商品編號獲取品名
        public HttpResponseBase Getprodbyid()
        {
            string jsonStr = String.Empty;
            try
            {
                int id;
                _iinvd = new IinvdMgr(mySqlConnectionString);
                DataTable dt = new DataTable();
                //if (int.TryParse(Request.Params["id"].ToString(), out id) && Request.Params["id"].ToString().Length == 6)
                //{//獲取商品編號
                //    dt = _iinvd.Getprodu(int.Parse(Request.Params["id"].ToString()));
                //}
                //else
                //{//獲取條碼
                    dt = _iinvd.Getprodubybar(Request.Params["id"].ToString());
               // }
                if (dt.Rows.Count > 0)
                {//pwy_dte_ctl是否是有效期控管的商品,cde_dt_shp:允出天數,cde_dt_var:允收天數,cde_dt_incr 保存天數
                    string spec = string.Empty;
                    if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name"].ToString()))
                    {
                        spec += dt.Rows[0]["spec_name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name1"].ToString()))
                    {
                        if (spec.Length > 0)
                        {
                            spec += ",";
                        }
                        spec += dt.Rows[0]["spec_name1"].ToString();
                    }
                    if (spec.Length > 0)
                    {
                        spec = "(" + spec + ")";
                    }
                    jsonStr = "{success:true,msg:\"" + dt.Rows[0]["product_name"] + spec + "\",locid:'" + dt.Rows[0]["loc_id"].ToString().ToUpper() + "',item_id:'" + dt.Rows[0]["item_id"] + "',day:'" + dt.Rows[0]["cde_dt_var"] + "',cde_dt_shp:'" + dt.Rows[0]["cde_dt_shp"] + "',pwy_dte_ctl:'" + dt.Rows[0]["pwy_dte_ctl"] + "',cde_dt_var:'" + dt.Rows[0]["cde_dt_var"] + "',cde_dt_incr:'" + dt.Rows[0]["cde_dt_incr"] + "',vendor_id:'" + dt.Rows[0]["vendor_id"] + "'}";//返回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.º 5
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();
        }