// 更新表Iinvd庫存鎖的狀態
        public JsonResult UpdateIinvdActive()
        {
            string jsonStr = string.Empty;
            try
            {
                _iinvd = new IinvdMgr(mySqlConnectionString);
                Iinvd nvd = new Iinvd();
                IialgQuery q = new IialgQuery();
                _iagMgr = new IialgMgr(mySqlConnectionString);

                int id = Convert.ToInt32(Request.Params["id"]);
                string active = Request.Params["active"];
                string lock_id = Request.Params["lock_id"];
                if (!string.IsNullOrEmpty(Request.Params["po_id"].ToString()))
                {
                    q.po_id = Request.Params["po_id"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["remarks"].ToString()))
                {
                    q.remarks = Request.Params["remarks"].ToString();
                }
                if (active == "H")
                {
                    nvd.ista_id = "A";
                    nvd.qity_id = 0;
                }
                else if (active == "A")
                {
                    nvd.qity_id = Convert.ToInt32(lock_id);
                    nvd.ista_id = "H";
                }
                nvd.row_id = id;
                nvd.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                nvd.change_dtim = DateTime.Now;
                if (_iinvd.UpdateIinvdLock(nvd, q) > 0)
                {
                    //加鎖成功往iialg插入一條數據;解鎖不需要記錄
                    if (active == "A")
                    {
                        Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault();
                        q.loc_id = store.plas_loc_id;
                        q.item_id = store.item_id;
                        q.iarc_id = "KS";
                        q.qty_o = store.prod_qty;
                        q.type = 1;
                        q.adj_qty = -store.prod_qty;
                        q.create_dtim = DateTime.Now;
                        q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                        q.made_dt = store.made_date;
                        q.cde_dt = store.cde_dt;
                        if (_iagMgr.insertiialg(q) > 0)
                        {
                            Caller call = new Caller();
                            call = (System.Web.HttpContext.Current.Session["caller"] as Caller);
                            ProductItem proitem = new ProductItem();
                            _proditemMgr = new ProductItemMgr(mySqlConnectionString);
                            int item_stock = store.prod_qty;
                            proitem.Item_Stock = -item_stock;
                            proitem.Item_Id = store.item_id;
                            string path = "/WareHouse/KutiaoAddorReduce";
                            _proditemMgr.UpdateItemStock(proitem, path, call);
                            return Json(new { success = "true" });
                        }
                        else
                        {

                            return Json(new { success = "false" });
                        }
                    }
                    else
                    {
                        Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault();
                        q.loc_id = store.plas_loc_id;
                        q.item_id = store.item_id;
                        q.iarc_id = "KS";
                        q.qty_o = 0;
                        q.type = 1;
                        q.adj_qty = store.prod_qty;
                        q.create_dtim = DateTime.Now;
                        q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                        q.made_dt = store.made_date;
                        q.cde_dt = store.cde_dt;
                        if (_iagMgr.insertiialg(q) > 0)
                        {
                            Caller call = new Caller();
                            call = (System.Web.HttpContext.Current.Session["caller"] as Caller);
                            ProductItem proitem = new ProductItem();
                            _proditemMgr = new ProductItemMgr(mySqlConnectionString);
                            int item_stock = store.prod_qty;
                            proitem.Item_Stock = item_stock;
                            proitem.Item_Id = store.item_id;
                            string path = "/WareHouse/KutiaoAddorReduce";
                            _proditemMgr.UpdateItemStock(proitem, path, call);
                            return Json(new { success = "true" });
                        }
                        else
                        {

                            return Json(new { success = "false" });
                        }
                    }
                }
                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" });
            }
        }