Пример #1
0
        public HttpResponseBase aboutmadetime()
        {
            string jsonStr = string.Empty;
            int result = 0;
            DataTable dt = new DataTable();
            try
            {
                int userId = (Session["caller"] as Caller).user_id;
                DateTime nowtimes = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                int type_id = 0;//類型
                int days = 0;
                int row_id = int.Parse(Request.Params["row_id"]);
                string cde_dtormade_dt = Request.Params["cde_dtormade_dt"];

                string y_cde_dtormade_dt = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["y_cde_dtormade_dt"]))
                {
                    y_cde_dtormade_dt = Request.Params["y_cde_dtormade_dt"];//原來的日期
                }
                if (!string.IsNullOrEmpty(Request.Params["type_id"]))
                {
                    type_id = Convert.ToInt32(Request.Params["type_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["datetimeday"]))
                {
                    days = Convert.ToInt32(Request.Params["datetimeday"]);
                }

                IinvdQuery invd = new IinvdQuery();
                IinvdQuery newinvd = new IinvdQuery();
                IialgQuery ialg = new IialgQuery();
                newinvd.change_user = userId;
                newinvd.change_dtim = DateTime.Now;
                if (!string.IsNullOrEmpty(Request.Params["sloc_id"]))
                {
                    invd.plas_loc_id = Convert.ToString(Request.Params["sloc_id"]).ToUpper();
                    ialg.loc_id = invd.plas_loc_id;
                }
                if (!string.IsNullOrEmpty(Request.Params["prod_id"]))
                {
                    invd.item_id = Convert.ToUInt32(Request.Params["prod_id"]);
                    ialg.item_id = invd.item_id;
                }
                if (!string.IsNullOrEmpty(Request.Params["prod_qtys"]))
                {
                    invd.prod_qty = Convert.ToInt32(Request.Params["prod_qtys"]);
                    ialg.qty_o = invd.prod_qty;
                }
                if (!string.IsNullOrEmpty(Request.Params["remarks"]))
                {
                    invd.remarks = Request.Params["remarks"];
                    ialg.remarks = invd.remarks;
                }
                if (!string.IsNullOrEmpty(Request.Params["po_id"]))
                {
                    ialg.po_id = Request.Params["po_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["iarc_id"]))
                {
                    ialg.iarc_id = Request.Params["iarc_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["doc_no"]))
                {
                    ialg.doc_no = Request.Params["doc_no"];
                }
                ialg.create_user = userId;
                invd.change_user = userId;
                ialg.create_dtim = DateTime.Now;
                invd.change_dtim = DateTime.Now;
                invd.row_id = row_id;
                if (type_id == 1)//表示編輯的是製造日期
                {
                    invd.made_date = DateTime.Parse(cde_dtormade_dt);
                    invd.cde_dt = invd.made_date.AddDays(days);//有效日期
                    if (invd.made_date > nowtimes)//已經過期
                    {
                        jsonStr = "{success:true,msg:1}";//1表示有效日期不能小於當前日期
                    }
                    else
                    {
                        _ipalet = new PalletMoveMgr(mySqlConnectionString);
                        _iialgMgr = new IialgMgr(mySqlConnectionString);
                        result = _ipalet.selectcount(invd);
                        #region 往iialg表中插入時間修改記錄
                        ialg.made_dt = DateTime.Parse(y_cde_dtormade_dt);//原來的日期
                        ialg.c_made_dt = DateTime.Parse(cde_dtormade_dt);//改后的日期
                        ialg.cde_dt = DateTime.Parse(y_cde_dtormade_dt).AddDays(days);//原來的有效日期
                        ialg.c_cde_dt = DateTime.Parse(cde_dtormade_dt).AddDays(days);//修改后的有效日期
                        ialg.adj_qty = 0;
                        if (string.IsNullOrEmpty(ialg.iarc_id))
                        {
                            ialg.iarc_id = "PC";
                        }
                        _iialgMgr.insertiialg(ialg);//往iialg中插入數據,用來記錄數據
                        #endregion
                        if (result > 0)//大於0表示裡面存在一樣子的值
                        {
                            dt = _ipalet.selectrow_id(invd);//獲取這個重複的row_id
                            newinvd.row_id = Convert.ToInt32(dt.Rows[0][0]);
                            newinvd.prod_qty = Convert.ToInt32(dt.Rows[0][1]) + invd.prod_qty;

                            if (_ipalet.UpdateordeleteIinvd(invd, newinvd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                        else
                        {
                            if (_ipalet.updatemadedate(invd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                    }
                }
                else if (type_id == 2)//表示有效日期
                {
                    invd.cde_dt = DateTime.Parse(cde_dtormade_dt);
                    invd.made_date = invd.cde_dt.AddDays(days * (-1));
                    if (invd.made_date > nowtimes)
                    {
                        jsonStr = "{success:true,msg:1}";//1表示有效日期不能小於當前日期
                    }
                    else
                    {
                        _ipalet = new PalletMoveMgr(mySqlConnectionString);
                        _iialgMgr = new IialgMgr(mySqlConnectionString);
                        result = _ipalet.selectcount(invd);
                        #region 往iialg表中插入時間修改記錄
                        ialg.cde_dt = DateTime.Parse(y_cde_dtormade_dt);//原來的有效日期日期
                        ialg.c_cde_dt = DateTime.Parse(cde_dtormade_dt);//改后的有效日期日期
                        ialg.made_dt = DateTime.Parse(y_cde_dtormade_dt).AddDays(days * (-1));//原來的製造日期
                        ialg.c_made_dt = DateTime.Parse(cde_dtormade_dt).AddDays(days * (-1));//修改后製造日期
                        ialg.adj_qty = 0;
                        if (string.IsNullOrEmpty(ialg.iarc_id))
                        {
                            ialg.iarc_id = "PC";
                        }
                        _iialgMgr.insertiialg(ialg);//往iialg中插入數據,用來記錄數據
                        #endregion
                        if (result > 0)//大於0表示裡面存在一樣子的值
                        {
                            dt = _ipalet.selectrow_id(invd);//獲取這個重複的row_id
                            newinvd.row_id = Convert.ToInt32(dt.Rows[0][0]);
                            newinvd.prod_qty = Convert.ToInt32(dt.Rows[0][1]) + invd.prod_qty;
                            if (_ipalet.UpdateordeleteIinvd(invd, newinvd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                        else
                        {
                            if (_ipalet.updatemadedate(invd) > 0)
                            {
                                jsonStr = "{success:true,msg:2}";//修改成功
                            }
                            else
                            {
                                jsonStr = "{success:false,msg:3}";//修改失敗
                            }
                        }
                    }
                }
            }
            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;
        }
Пример #2
0
        public HttpResponseBase GeKuCunList()
        {
            string json = string.Empty;
            IinvdQuery Iinvd = new IinvdQuery();

            if (!string.IsNullOrEmpty(Request.Params["prod_id"]))//查詢商品编号
            {
                if (Request.Params["prod_id"].Length == 6)
                {
                    Iinvd.item_id = UInt32.Parse(Request.Params["prod_id"]);
                }
                else
                {
                    Iinvd.upc_id = Request.Params["prod_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["sloc_id"]))
                {
                    Iinvd.plas_loc_id = Request.Params["sloc_id"].ToString().Trim().ToUpper();
                }
                Iinvd.ista_id = "A";
            }
            try
            {
                List<IinvdQuery> store = new List<IinvdQuery>();
                _ipalet = new PalletMoveMgr(mySqlConnectionString);
                store = _ipalet.GetPalletList(Iinvd);//查询的是副料位
                foreach (var item in store)
                {
                    item.cde_dt_make = item.made_date;
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                json = "{success:true,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;
        }
Пример #3
0
  //
  public HttpResponseBase selectproductexttime()
  {
      string json = string.Empty;
      int result = 0;
      List<ProductExt> lsPt = new List<ProductExt>();
      try
      {
          string Item_id = "";
          if (!string.IsNullOrEmpty(Request.Params["item_id"]))//查詢商品编号
          {
              Item_id = Request.Params["item_id"];
          }
          _ipalet = new PalletMoveMgr(mySqlConnectionString);
          lsPt = _ipalet.selectproductexttime(Item_id);
          foreach (var item in lsPt)
          {
              result = item.Cde_dt_incr;
          }
          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}";
      }
      this.Response.Clear();
      this.Response.Write(json);
      this.Response.End();
      return this.Response;
 }
Пример #4
0
 public void OutPalletSuggest()
 {
     IinvdQuery model = new IinvdQuery();
     _iinvd = new IinvdMgr(mySqlConnectionString);
     _ipalet = new PalletMoveMgr(mySqlConnectionString);
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["item_id"]))
         {
             string itemid = Request.Params["item_id"];
             DataTable dt = _ipalet.GetProdInfo(itemid);
             if (dt.Rows.Count > 0)
             {
                 model.item_id = uint.Parse(dt.Rows[0]["item_id"].ToString());
             }
             else
             {
                 model.item_id = 0;
             }
         }
         if (!string.IsNullOrEmpty(Request.Params["locid"]))
         {
             model.loc_id = Request.Params["locid"].ToUpper();
         }
         if (!string.IsNullOrEmpty(Request.Params["startIloc"]))
         {
             model.startIloc = Request.Params["startIloc"].ToUpper();
         }
         if (!string.IsNullOrEmpty(Request.Params["endIloc"]))
         {
             model.endIloc = Request.Params["endIloc"] + "Z";
             model.endIloc = model.endIloc.ToUpper();
         }
         if (!string.IsNullOrEmpty(Request.Params["number"]))
         {
             model.sums = int.Parse(Request.Params["number"]);
         }
         if (Request.Params["Auto"] == "true")
         {
             model.auto = 1;
         }
         DataTable dtHZ=_iinvd.ExportExcel(model);
         if(dtHZ.Rows.Count>0)
         {
             string fileName = "補貨建議報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
             MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "補貨建議報表(FIFO;副料位到主料位_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")");
             Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
             Response.BinaryWrite(ms.ToArray());
         }
         else
         {
             Response.Clear();
             this.Response.Write("無數據存在<br/>");
         }
     }
     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);
     }
 }
Пример #5
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;
        }
Пример #6
0
 public JsonResult UpPalletTime()
 {
     try
     {
         int row_id = int.Parse(Request.Params["row_id"]);
         string cde_dt = Request.Params["cde_dt"];
         IinvdQuery invd = new IinvdQuery();
         invd.row_id = row_id;
         invd.cde_dt = DateTime.Parse(cde_dt);
         invd.made_date = invd.cde_dt.AddDays(-invd.cde_dt_incr);
         _ipalet = new PalletMoveMgr(mySqlConnectionString);
         if (_ipalet.UpPalletTime(invd) > 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" });
     }
 }
Пример #7
0
 public HttpResponseBase GetProductInfoByLocId()
 {
     string jsonStr = String.Empty;
     try
     {
         string loc_id = Request.Params["loc_id"].ToString();
         DataTable dt = new DataTable();
         _ipalet = new PalletMoveMgr(mySqlConnectionString);
         dt = _ipalet.GetProductMsgByLocId(loc_id);
         if (dt.Rows.Count > 0)
         {
             jsonStr = "{success:true,msg:\"" + dt.Rows[0]["product_name"] + "\",item_id:'" + dt.Rows[0]["item_id"] + "',yunsongtype:'" + dt.Rows[0]["product_mode"] + "'}";//返回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,msg:0}";
     }
     this.Response.Clear();
     this.Response.Write(jsonStr.ToString());
     this.Response.End();
     return this.Response;
 }
Пример #8
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;
        }