Esempio n. 1
0
 public DataTable upcid(Iupc m)
 {
     try
     {
        return  _iupcdao.upcid(m);
     }
     catch (Exception ex)
     {
         throw new Exception("IupcMgr-->upcid-->" + ex.Message, ex);
     }
 }
Esempio n. 2
0
 public int Update(Iupc iupc)
 {
     try
     {
         return _iupcdao.Update(iupc);
     }
     catch (Exception ex)
     {
         throw new Exception("IupcMgr-->Update-->" + ex.Message, ex);
     }
 }
Esempio n. 3
0
 public int Insert(Iupc iupc)
 {
     try
     {
         return _iupcdao.Insert(iupc); 
     }
     catch (Exception ex)
     {
         throw new Exception("IupcMgr-->Insert-->" + ex.Message, ex);
     }
 }
Esempio n. 4
0
 public string  IsExist(Iupc iupc)
 {
  try
     {
         return _iupcdao.IsExist(iupc); 
     }
     catch (Exception ex)
     {
         throw new Exception("IupcMgr-->IsExist-->" + ex.Message, ex);
     }
  
 }
Esempio n. 5
0
 public int Delete(Iupc iupc)
 {
     string sbSql = String.Empty;
     try
     {
         sbSql = String.Format("set sql_safe_updates = 0; delete  from iupc where row_id={0} ;set sql_safe_updates = 1;", iupc.row_id);
         return _access.execCommand(sbSql);
     }
     catch (Exception ex)
     {                
         throw new Exception("IupcDao-->Delete-->" + ex.Message + sbSql, ex);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 撿貨——調度流程頁面加載數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetMarkTallyTW()
        {
            string json = string.Empty;
            string ord_id = Request.Params["ord_id"];
            string type = Request.Params["type"];
            AseldQuery ase = new AseldQuery();
            Aseld m = new Aseld();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["ord_id"]))
                {
                    ase.ord_id = int.Parse(Request.Params["ord_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["freight_set"]))
                {
                    ase.freight_set = Request.Params["freight_set"].Substring(0, 1);
                }
                //if (!string.IsNullOrEmpty(Request.Params["deliver_code"]))
                //{
                //    ase.deliver_code = Request.Params["deliver_code"].Substring(0, 1);
                //}
                if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                {
                    if (Request.Params["item_id"].Length == 6)
                    {
                        ase.item_id = uint.Parse(Request.Params["item_id"]);
                    }
                    else
                    {
                        ase.upc_id = Request.Params["item_id"];
                    }
                }
                _iasdMgr = new AseldMgr(mySqlConnectionString);
                DataTable dt = _iasdMgr.GetOrderProductInformation(ase);
                //0代表加載工作代號
                if (type == "0")//141980010
                {
                    if (dt.Rows.Count > 0)
                    {
                        json = "\"" + "assg_id" + "\"" + ":" + "\"" + dt.Rows[0]["assg_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_code" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_code"].ToString() + "\"";
                    }
                }
                else
                {
                    if (dt.Rows.Count > 0)
                    {
                        //json = "\"" + "assg_id" + "\"" + ":" + "\"" + dr["assg_id"].ToString() + "\"";
                        if (!string.IsNullOrEmpty(dt.Rows[0]["prod_sz"].ToString()))
                        {
                            json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " (" + dt.Rows[0]["prod_sz"].ToString() + ")\"";
                        }
                        else
                        {
                            json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " " + dt.Rows[0]["prod_sz"].ToString() + "\"";
                        }
                        //json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " " + dt.Rows[0]["prod_sz"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "seld_id" + "\"" + ":" + "\"" + dt.Rows[0]["seld_id"].ToString() + "\"";//row_id.唯一的
                        json += ",\r\n" + "\"" + "ord_qty" + "\"" + ":" + "\"" + dt.Rows[0]["ord_qty"].ToString() + "\"";//訂貨量
                        json += ",\r\n" + "\"" + "out_qty" + "\"" + ":" + "\"" + dt.Rows[0]["out_qty"].ToString() + "\"";//缺貨量
                        json += ",\r\n" + "\"" + "ordd_id" + "\"" + ":" + "\"" + dt.Rows[0]["ordd_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_id" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_code" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_code"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "note_order" + "\"" + ":" + "\"" + dt.Rows[0]["note_order"].ToString() + "\"";
                        if (!string.IsNullOrEmpty(dt.Rows[0]["cde_dt_shp"].ToString()))
                        {
                            json += ",\r\n" + "\"" + "cde_dt_shp" + "\"" + ":" + "\"" + dt.Rows[0]["cde_dt_shp"].ToString() + "\"";//商品的允出天數

                        }
                        else
                        {
                            json += ",\r\n" + "\"" + "cde_dt_shp" + "\"" + ":" + "\"" + "999999" + "\"";//商品的允出天數
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["pwy_dte_ctl"].ToString()))
                        {
                            json += ",\r\n" + "\"" + "pwy_dte_ctl" + "\"" + ":" + "\"" + dt.Rows[0]["pwy_dte_ctl"].ToString() + "\"";//有效期控管
                        }
                        else
                        {
                            json += ",\r\n" + "\"" + "pwy_dte_ctl" + "\"" + ":" + "\"" + "N" + "\"";//有效期控管
                        }
                        #region 查詢商品信息同時把wust_id更改為BSY
                        m.wust_id = "BSY";
                        m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                        if (!string.IsNullOrEmpty(dt.Rows[0]["seld_id"].ToString()))
                        {
                            m.seld_id = int.Parse(dt.Rows[0]["seld_id"].ToString());
                        }
                        _iasdMgr.Updwust(m);
                        #endregion
                    }
                    else
                    {//判斷條碼輸入的是否正確
                        DataTable data = new DataTable();
                        Iupc i = new Iupc();
                        _IiupcMgr = new IupcMgr(mySqlConnectionString);
                        if (!string.IsNullOrEmpty(ase.upc_id))
                        {
                            i.upc_id = ase.upc_id;
                            data = _IiupcMgr.upcid(i);
                            if (data.Rows.Count > 0)
                            {
                                json = "\"" + "item_id" + "\"" + ":" + "\"" + data.Rows[0]["item_id"].ToString() + "\"";
                            }
                        }
                    }
                }
                json = "{success:true,data:\r\n  {\r\n" + json + "\r\n} \r\n" + "}";
            }
            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:true,data:\r\n  {\r\n" + "" + "\r\n} \r\n" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 7
0
        //收貨上架匯出
        public void IinvdExcelList()
        {
            string json = string.Empty;
            IinvdQuery iivd = new IinvdQuery();
            DataTable dtIinvdExcel = new DataTable();
            DateTime dtime = DateTime.Now;
            _IiupcMgr = new IupcMgr(mySqlConnectionString);
            try
            {
                iivd.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                iivd.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                string content = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["search_type"]))
                {
                    iivd.serch_type = int.Parse(Request.Params["search_type"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcontent"]) && Request.Params["searchcontent"].Trim().Length > 0)
                    {

                        switch (iivd.serch_type)
                        {
                            case 1:
                            case 2:
                                iivd.serchcontent = Request.Params["searchcontent"].Trim();
                                break;
                            case 3:
                                #region 之後的更改
                                content = Request.Params["searchcontent"].Replace(',', ',').Replace('|', ',').Replace(' ', ',');//.Replace(' ',',')
                                string[] list = content.Split(',');
                                string test = "^[0-9]*$";
                                int count = 0;//實現最後一個不加,
                                for (int i = 0; i < list.Length; i++)
                                {
                                    if (!string.IsNullOrEmpty(list[i]))
                                    {
                                        if (Regex.IsMatch(list[i], test))
                                        {
                                            count = count + 1;
                                            if (count == 1)
                                            {
                                                iivd.serchcontent = list[i];
                                            }
                                            else
                                            {
                                                iivd.serchcontent = iivd.serchcontent + "," + list[i];
                                            }
                                        }
                                        else
                                        {
                                            iivd.serchcontent = iivd.serchcontent + list[i] + ",";
                                        }
                                    }
                                }
                                #endregion
                                break;
                            default:
                                break;
                        }
                    }
                }
                DateTime time;
                if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
                {
                    iivd.starttime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
                {
                    iivd.endtime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                List<IinvdQuery> store = new List<IinvdQuery>();
                _iinvd = new IinvdMgr(mySqlConnectionString);
                store = _iinvd.GetIinvdExprotList(iivd);
                #region 列名
                dtIinvdExcel.Columns.Add("商品細項編號", typeof(String));
                dtIinvdExcel.Columns.Add("商品名稱", typeof(String));
                dtIinvdExcel.Columns.Add("數量", typeof(String));
                dtIinvdExcel.Columns.Add("有效日期", typeof(String));
                dtIinvdExcel.Columns.Add("上架料位", typeof(String));
                dtIinvdExcel.Columns.Add("主料位", typeof(String));
                dtIinvdExcel.Columns.Add("允收天數", typeof(String));
                dtIinvdExcel.Columns.Add("建立日期", typeof(String));
                dtIinvdExcel.Columns.Add("建立人員", typeof(String));
                dtIinvdExcel.Columns.Add("鎖定狀態", typeof(String));
                dtIinvdExcel.Columns.Add("庫鎖原因", typeof(String));
                dtIinvdExcel.Columns.Add("店內碼", typeof(String));
                dtIinvdExcel.Columns.Add("國際碼", typeof(String));
                dtIinvdExcel.Columns.Add("庫鎖備註", typeof(String));
                #endregion
                for (int i = 0; i < store.Count; i++)
                {
                    string upc = "";
                    Iupc iu = new Iupc();
                    DataRow newRow = dtIinvdExcel.NewRow();
                    newRow[0] = store[i].item_id.ToString();
                    #region 添加店內碼
                    if (DateTime.TryParse(store[i].cde_dt.ToString(), out dtime))
                    {
                        upc = CommonFunction.GetUpc(store[i].item_id.ToString(), store[i].vendor_id.ToString(), dtime.ToString("yyMMdd"));
                    }
                    else
                    {
                        upc = CommonFunction.GetUpc(store[i].item_id.ToString(), store[i].vendor_id.ToString(), dtime.ToString("yyMMdd"));
                    }
                    iu.upc_id = upc;
                    iu.item_id = uint.Parse(store[i].item_id.ToString());
                    iu.upc_type_flg = "2";//店內碼
                    iu.create_user = (Session["caller"] as Caller).user_id;
                    string result = _IiupcMgr.IsExist(iu);//是否有重複的條碼
                    if (result == "0")
                    {
                        _IiupcMgr.Insert(iu);
                    }
                    #endregion
                    newRow[1] = store[i].product_name.ToString();
                    newRow[2] = store[i].prod_qty.ToString();
                    newRow[3] = store[i].cde_dt.ToString();
                    newRow[4] = store[i].plas_loc_id.ToString();
                    newRow[5] = store[i].loc_id.ToString();
                    newRow[6] = store[i].cde_dt_var.ToString();
                    newRow[7] = store[i].create_dtim.ToString();
                    newRow[8] = store[i].user_name.ToString();
                    newRow[9] = store[i].ista_id.ToString();
                    newRow[10] = store[i].qity_name.ToString();
                    newRow[11] = " " + upc;
                    newRow[12] = " " + store[i].upc_id.ToString();
                    iivd.item_id = uint.Parse(store[i].item_id.ToString());
                    iivd.plas_loc_id = store[i].plas_loc_id.ToString();
                    iivd.made_date = store[i].made_date;
                    if (store[i].ista_id.ToString() == "H")
                    {
                        newRow[13] = _iinvd.remark(iivd);
                    }
                    else
                    {
                        newRow[13] = "";
                    }
                    dtIinvdExcel.Rows.Add(newRow);
                }
                if (dtIinvdExcel.Rows.Count > 0)
                {
                    string fileName = "收貨上架_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    MemoryStream ms = ExcelHelperXhf.ExportDT(dtIinvdExcel, "收貨上架_" + 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);
            }
        }
Esempio n. 8
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;
        }
Esempio n. 9
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;
        }
Esempio n. 10
0
        //條碼刪除
        public HttpResponseBase IupcDelete()
        {
            string jsonStr = String.Empty;
            Iupc iupc = new Iupc();
            _IiupcMgr = new IupcMgr(mySqlConnectionString);
            if (!String.IsNullOrEmpty(Request.Params["rowid"]))
            {
                try
                {
                    foreach (string rid in Request.Params["rowid"].ToString().Split('|'))
                    {
                        if (!string.IsNullOrEmpty(rid))
                        {
                            iupc.row_id = Convert.ToInt32(rid);
                            _IiupcMgr.Delete(iupc);
                        }
                    }
                    jsonStr = "{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);
                    jsonStr = "{success:false}";
                }
            }

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Esempio n. 11
0
        //條碼新增修改
        public HttpResponseBase SaveIupc()
        {
            string json = string.Empty;
            try
            {
                Iupc iupc = new Iupc();
                iupc.item_id = uint.Parse(Request.Params["item_id"].Trim());
                iupc.upc_id = Request.Params["upc_id"].Trim();
                if (!string.IsNullOrEmpty(Request.Params["upc_type_flg"]))
                {
                    iupc.upc_type_flg = Request.Params["upc_type_flg"];
                }

                if (!string.IsNullOrEmpty(Request.Params["row_id"]))
                {
                    iupc.row_id = int.Parse(Request.Params["row_id"]);
                }
                else
                {
                    iupc.row_id = 0;
                }
                _IiupcMgr = new IupcMgr(mySqlConnectionString);
                string result = _IiupcMgr.IsExist(iupc);
                if (result == "0")
                {
                    //新增
                    if (string.IsNullOrEmpty(Request.Params["row_id"]))
                    {
                        iupc.create_user = (Session["caller"] as Caller).user_id;
                        iupc.create_dtim = DateTime.Now;
                        _IiupcMgr.Insert(iupc);
                        json = "{success:true,msg:\"" + "新增成功!" + "\"}";
                    }
                    //修改
                    else
                    {
                        iupc.row_id = int.Parse(Request.Params["row_id"]);
                        _IiupcMgr.Update(iupc);
                        json = "{success:true,msg:\"" + "修改成功!" + "\"}";
                    }
                }
                else
                {
                    json = "{success:false,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:\"" + "" + "\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 12
0
        public DataTable upcid(Iupc m)
        {//查詢該itemid 下的所有條碼
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat("SELECT item_id from iupc where upc_id='{0}'; ", m.upc_id);
                return _access.getDataTable(sb.ToString());
            }
            catch(Exception ex)
            {
                throw new Exception("IupcDao-->upcid-->" + ex.Message+"sql:" + sb.ToString(), ex);
            }

        }
Esempio n. 13
0
        public int Update(Iupc iupc)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"UPDATE iupc set item_id='{0}',upc_id='{1}',upc_type_flg='{2}' where row_id='{3}'", iupc.item_id, iupc.upc_id, iupc.upc_type_flg, iupc.row_id);
            try
            {
                return _access.execCommand(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("IupcDao-->Update-->" + ex.Message + sql.ToString(), ex);
            }

        }
Esempio n. 14
0
 public int Insert(Iupc iupc)
 {
     StringBuilder sql = new StringBuilder();
     sql.AppendLine(@"insert into iupc (upc_id,suppr_upc,lst_ship_dte,lst_rct_dte,create_dtim,create_user,upc_type_flg,item_id) ");
     sql.AppendFormat(@"VALUES ('{0}','{1}','{2}','{3}',", iupc.upc_id, iupc.suppr_upc,CommonFunction.DateTimeToString(iupc.lst_ship_dte),CommonFunction.DateTimeToString(iupc.lst_rct_dte));
     sql.AppendFormat(@"'{0}','{1}','{2}','{3}')", CommonFunction.DateTimeToString(iupc.create_dtim), iupc.create_user, iupc.upc_type_flg, iupc.item_id);
     try
     {
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("IupcDao-->Insert-->" + ex.Message + sql.ToString(), ex);
     }
 }
Esempio n. 15
0
 public HttpResponseBase Judgeupcid()
 {
     string jsonStr = "";
     _IiupcMgr = new IupcMgr(mySqlConnectionString);
     Iupc m = new Iupc();
     DataTable dt = new DataTable();
     uint id = 0;
     try
     {
         if (uint.TryParse(Request.Params["item_id"].ToString(), out id))
         {
             m.item_id = id;
             m.upc_id = Request.Params["upc_id"].ToString();
             if (m.upc_id.ToString() == m.item_id.ToString())
             {//如果輸入商品編號也可以通過
                 jsonStr = "{success:true}";
             }
             else
             {//獲取條碼
                 if (!string.IsNullOrEmpty(m.upc_id))
                 {
                     dt = _IiupcMgr.upcid(m);
                     if (dt.Rows.Count == 0)
                     {
                         jsonStr = "{success:false,msg:2}";
                     }
                     for (int i = 0; i < dt.Rows.Count; i++)
                     {
                         if (dt.Rows[i]["item_id"].ToString() == id.ToString())
                         {
                             jsonStr = "{success:true}";
                         }
                         else
                         {
                             jsonStr = "{success:false,msg:1,itemid:" + dt.Rows[i]["item_id"].ToString() + "}";
                         }
                     }
                 }
             }
         }
     }
     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;
 }
Esempio n. 16
0
        //根據upcid獲取item_id
        public HttpResponseBase GetItemidByUpcid()
        {
            string json = string.Empty;
            _IiupcMgr = new IupcMgr(mySqlConnectionString);
            _iproductitemMgr = new ProductItemMgr(mySqlConnectionString);
            Iupc m = new Iupc();
            DataTable dt = new DataTable();
            bool isUpc = true;
            try
            {
                //獲取條碼
                if (!string.IsNullOrEmpty(Request.Params["upc_id"]))
                {
                    m.upc_id = Request.Params["upc_id"].ToString().Trim();
                    //6位整數時先判斷輸入的是否為item_id
                    Regex reg = new Regex("^\\d{6}$");
                    if (reg.IsMatch(m.upc_id))
                    {
                        ProductItemQuery query = new ProductItemQuery();
                        query.Item_Id = Convert.ToUInt32(m.upc_id);
                        List<ProductItemQuery> store = _iproductitemMgr.GetProductItemByID(query);
                        if (store.Count == 0)
                        {
                            isUpc = true;
                        }
                        else if (store.Count > 1)
                        {
                            isUpc = true;
                        }
                        else
                        {
                            json = "{success:true,msg:1,itemid:" + query.Item_Id + "}";
                            isUpc = false;
                        }
                    }
                    if (isUpc)
                    {
                        dt = _IiupcMgr.upcid(m);
                        if (dt.Rows.Count == 0)
                        {
                            json = "{success:false,msg:0}";
                        }
                        else if (dt.Rows.Count > 1)
                        {
                            json = "{success:false,msg:2}";
                        }
                        else
                        {
                            json = "{success:true,msg:1,itemid:" + dt.Rows[0]["item_id"].ToString() + "}";
                        }
                    }

                }
            }
            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;
        }
Esempio n. 17
0
        /// <summary>
        /// 判斷輸入的商品編號和條碼編號是否有效
        /// </summary>
        /// <param name="iupc"></param>
        /// <returns></returns>
        public string IsExist(Iupc iupc)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder str=new StringBuilder();
            StringBuilder sb =new StringBuilder();
            int i = 0;
            try
            {
                sql.AppendFormat(@"SELECT item_id from product_item where item_id='{0}'", iupc.item_id);//有無商品
                if (_access.getDataTable(sql.ToString()).Rows.Count > 0)//判斷這個商品是否存在
                {
                    sql.Clear();
                    sql.AppendFormat(" SELECT row_id from iupc WHERE upc_id='{0}' ", iupc.upc_id);//有無條碼,不管國際國內,都不能重複

                    i = _access.getDataTable(sql.ToString()).Rows.Count;
                    str.AppendFormat(" SELECT row_id from iupc WHERE item_id='{0}' and upc_type_flg=1 ", iupc.item_id);//這個商品有無國際碼
                    int result = _access.getDataTable(str.ToString()).Rows.Count;
                    sb.AppendFormat(" select row_id from iupc where row_id='{0}' and upc_type_flg=1 ",iupc.row_id);//
                    int sbresult=_access.getDataTable(sb.ToString()).Rows.Count;
                    if (iupc.row_id == 0)//如果是新增
                    {
                        if (i < 1)//條碼不重複
                        {
                            if (iupc.upc_type_flg == "1")//如果新增的是國際碼,那個先看這個商品是否已有國際碼
                            {
                                if (result < 1)//沒有國際碼新增
                                {
                                    return "0";
                                }
                                else
                                {
                                    return "3";
                                }
                            }
                            else//店內碼隨便添加
                            {
                                return "0";
                            }
                        }
                        else
                        {
                            return "2";//條碼重複
                        }
                    }
                    //修改
                    else
                    {//

                        if (i == 0)//條碼不重複
                        {
                            if (iupc.upc_type_flg == "1")//修改城國際碼
                            {
                                if (result < 1)//沒有國際碼可以改
                                {
                                    return "0";
                                }
                                else//有國際碼,判斷是否是這個
                                {
                                    //sb.AppendFormat(" and  upc_id='{0}' ", iupc.upc_id);
                                    if (sbresult==1)//國際改國際
                                    {
                                        return "0";
                                    }
                                    else
                                    {
                                        return "3";//此商品已有國際碼
                                    }
                                }

                            }
                            else
                            {
                                return "0";
                            }

                        }
                        else //條碼重複,有可能是自身
                        {
                            //是自身還是別人的條碼
                            sql.AppendFormat(" and  row_id='{0}' ", iupc.row_id);
                            if (_access.getDataTable(sql.ToString()).Rows.Count == 1)//重複的是自身
                            {
                                if (iupc.upc_type_flg == "1")//修改成國際碼 
                                {
                                    //判斷自身是否已有國際碼
                                    str.AppendFormat(" and upc_id<>'{0}' ", iupc.upc_id);
                                    if (_access.getDataTable(str.ToString()).Rows.Count < 1)
                                    {
                                        return "0";
                                    }
                                    else 
                                    {
                                        return "3";
                                    }
                                    //sb.AppendFormat(" and  upc_id='{0}' ", iupc.upc_id);//國際改國際
                                    //if (_access.getDataTable(sql.ToString()).Rows.Count == 1)
                                    //{
                                    //    return "0";
                                    //}
                                    //else //普通改國際--沒國際碼
                                    //{
                                    //    if (result < 1)
                                    //    {
                                    //        return "0";
                                    //    }
                                    //    else
                                    //    {//已有國際碼
                                    //        return "3";
                                    //    }

                                    //}
                                }
                                else //修改普通碼
                                {
                                    return "0";
                                }

                            }
                            else //不是自身,條碼重複
                            {
                                return "2";
                            }
                        }
                    }
                    
                }
                else
                {
                    return "1";
                }
            }
            catch(Exception ex)
            {
                throw new Exception("IupcDao-->IsExist-->" + ex.Message + sql, ex);
            }
        }