Пример #1
0
 //通過工作代號判斷在表中是否存在
 public HttpResponseBase GetAseldMasterAssgCount()
 {
     string json = string.Empty;
     Aseld ase = new Aseld();
     AseldMaster aseMaster = new AseldMaster();
     int count = 0;
     try
     {
         _aseldmasterMgr = new AseldMasterMgr(mySqlConnectionString);
         if (!String.IsNullOrEmpty(Request.Params["number"].ToString().Trim()))//如果是新增
         {
             aseMaster.assg_id = Request.Params["number"].ToString().Trim();
             ase.assg_id = aseMaster.assg_id;
         }
         ase.change_dtim = DateTime.Now;
         ase.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
         count = _aseldmasterMgr.SelectCount(aseMaster);
         _iasdMgr = new AseldMgr(mySqlConnectionString);
         if (count > 0)
         {//輸入的項目編號裡面有商品需要揀貨,把aseld裡面的scaned欄位初始化為0(主要在第二次揀貨時)
             _iasdMgr.UpdScaned(ase);
         }
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,data:" + count + "}";//返回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;
 }
Пример #2
0
        public HttpResponseBase GETMarkTallyWD()
        {
            StringBuilder sb = new StringBuilder();
            string json = String.Empty;
            AseldQuery m = new AseldQuery();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            int flag = 2;
            int try1 = 0;
            try
            {
                m.seld_id = Int32.Parse(Request.Params["seld_id"]);//aseld的流水號
                m.commodity_type = Request.Params["commodity_type"];//獲取寄倉2和調度3
                m.ord_qty = Int32.Parse(Request.Params["ord_qty"]);//需要訂貨數量
                if (Int32.TryParse(Request.Params["act_pick_qty"], out try1))
                {
                    m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);
                }
                else
                {
                    m.act_pick_qty = 0;
                }
                m.item_id = uint.Parse(Request.Params["item_id"]);
                m.out_qty = Int32.Parse(Request.Params["out_qty"]) - m.act_pick_qty;//缺貨數量
                m.act_pick_qty = m.ord_qty - m.out_qty;
                m.complete_dtim = DateTime.Now;
                m.assg_id = Request.Params["assg_id"];
                m.ord_id = Int32.Parse(Request.Params["ord_id"]);
                m.ordd_id = int.Parse(Request.Params["ordd_id"]);//商品細項編號。操作iwms_record需要
                m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                m.deliver_code = Request.Params["deliver_id"];
                m.deliver_id = int.Parse(m.deliver_code.Substring(1, m.deliver_code.Length - 1).ToString());
                if (m.out_qty == 0)
                {//揀完了,判斷缺貨數量是否為0
                    m.wust_id = "COM";
                }
                else
                {//沒拿夠貨物
                    m.wust_id = "SKP";
                }
                sb.Append(_iasdMgr.UpdAseld(m));
                if (m.commodity_type == "2")
                {
                    #region 寄倉--對庫存進行操作
                    Dictionary<string, string> dickuCun = new Dictionary<string, string>();
                    if (Int32.TryParse(Request.Params["act_pick_qty"], out try1))
                    {
                        if (!string.IsNullOrEmpty(Request.Params["pickRowId"]))
                        {
                            string[] iinvd = Request.Params["pickRowId"].Split(',');
                            string[] pick = Request.Params["pickInfo"].Split(',');
                            for (int i = 0; i < iinvd.Length; i++)
                            {
                                if (!dickuCun.Keys.Contains(iinvd[i]))
                                {
                                    dickuCun.Add(iinvd[i], pick[i]);
                                }
                                else
                                {
                                    dickuCun[iinvd[i]] = pick[i];
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_iasdMgr.updgry(m, dickuCun)))
                    {
                        sb.Append(_iasdMgr.updgry(m, dickuCun));
                    }
                    if (!string.IsNullOrEmpty(sb.ToString()))
                    {
                        _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    }
                    int ord = 1;
                    int cancel = 0;
                    int ord_id = 0;
                    #region  判斷項目狀態
                    if (_iasdMgr.SelCom(m) == 0)
                    {
                        ord = 0;
                        ord_id = m.ord_id;
                        //訂單揀貨完成,可以封箱
                    }
                    if (_iasdMgr.SelComA(m) == 0)
                    {
                        flag = 0;//項目訂單揀貨完成
                    }
                    if (ord == 0)
                    {//有沒有臨時取消的商品
                        if (_iasdMgr.SelComC(m) > 0)
                        {
                            cancel = 1; ord_id = m.ord_id;
                        }
                    }
                    #endregion
                    json = "{success:true,qty:'" + m.out_qty + "',flag:'" + flag + "',ord:'" + ord + "',cancel:'" + cancel + "',ord_id:'" + ord_id + "'}";//返回json數據  
                    //qty 該物品是否缺貨,如果為零揀貨完成,否則彈框提示缺貨數量。
                    //over:0表示該訂單已經揀貨完畢,如果qty為零則提示該訂單可以封箱,qty不為零則提示該訂單還缺物品的數量。不為零則不提示任何信息。
                    #endregion
                }
                else if (m.commodity_type == "3")
                {
                    #region 調度--對庫存進行操作
                    m.change_user = int.Parse((Session["caller"] as Caller).user_id.ToString());//操作iwms_record 需要插入create_uaer_id。对aseld中的change_user未做任何改变
                    m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);//下一步插入檢貨記錄表,每檢一次記錄一次,實際撿貨量以傳過來的值為標準
                    if (_iasdMgr.getTime(m).Rows.Count > 0)
                    {//獲取到有效期控管商品的保質期
                        m.cde_dt_incr = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_incr"].ToString());
                        m.cde_dt_shp = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_shp"].ToString());
                    }
                    if (!string.IsNullOrEmpty(Request.Params["cde_dt"]))
                    {//獲取有效日期算出製造日期
                        m.cde_dt = DateTime.Parse(Request.Params["cde_dt"]);
                        if (m.cde_dt_incr > 0)
                        {
                            m.made_dt = m.cde_dt.AddDays(-m.cde_dt_incr);
                        }
                        else
                        {
                            m.made_dt = DateTime.Now;
                        }
                    }
                    else if (!string.IsNullOrEmpty(Request.Params["made_dt"]))
                    {//獲取製造日期獲取有效日期
                        m.made_dt = DateTime.Parse(Request.Params["made_dt"]);
                        if (m.cde_dt_incr > 0)
                        {
                            m.cde_dt = m.made_dt.AddDays(m.cde_dt_incr);
                        }
                        else
                        {
                            m.cde_dt = DateTime.Now;
                        }
                    }
                    else
                    {//不是有效期控管
                        m.made_dt = DateTime.Now;
                        m.cde_dt = DateTime.Now;
                    }
                    if (m.act_pick_qty > 0)
                    {
                        sb.Append(_iasdMgr.AddIwsRecord(m));
                    }
                    //m.act_pick_qty = m.ord_qty - m.out_qty;
                    _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    int result = _iasdMgr.DecisionBulkPicking(m, 3);//判斷調度是否檢完,是否檢夠,是否可以裝箱

                    json = "{success:true,msg:'" + result + "'" + "}";//返回json數據  
                    #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);
                json = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #3
0
        //根據工作代號、細項編號 獲取商品數據
        /// <summary>
        /// 自動理貨 根據工作代號/細項編號/訂單號/出貨單號獲取所有商品信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetAllAseldList()
        {//判斷寄倉或者調度
            string json = String.Empty;

            AseldQuery m = new AseldQuery();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            int totalCount = 0;
            try
            {

                string search_type = Request.Params["search_type"].ToString().Trim();
                if (!string.IsNullOrEmpty(Request.Params["search_con"].ToString().Trim()))
                {
                    if (search_type == "assg_id")
                    {
                        m.assg_id = Request.Params["search_con"].ToString().Trim();
                    }
                    else if (search_type == "item_id")
                    {
                        m.item_id = Convert.ToUInt32(Request.Params["search_con"].ToString().Trim());
                    }
                    else if (search_type == "ord_id")
                    {
                        m.ord_id = Convert.ToInt32(Request.Params["search_con"].ToString().Trim());
                    }
                    else if (search_type == "deliver_code")
                    {
                        m.deliver_code = Request.Params["search_con"].ToString().Trim();
                    }
                    else
                    {

                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["start_time"]))
                {
                    m.start_time = Convert.ToDateTime(Convert.ToDateTime(Request.Params["start_time"]).ToString("yyyy-MM-dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"]))
                {
                    m.end_time = Convert.ToDateTime(Convert.ToDateTime(Request.Params["end_time"]).ToString("yyyy-MM-dd 23:59:59"));
                }
                
                list = _iasdMgr.GetAllAseldList(m, out totalCount);
                foreach (var item in list)
                {
                    m.seld_id = item.seld_id;
                }
                m.wust_id = "BSY";
                m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                _iasdMgr.Updwust(m);
                json = "{success:true,totalCount:"+ totalCount +",data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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.ToString());
            this.Response.End();
            return this.Response;
        }
Пример #4
0
        //根據工作代號、細項編號 獲取商品數據
        public HttpResponseBase GetAseldListByItemid()
        {//判斷寄倉或者調度
            string json = String.Empty;

            Aseld m = new Aseld();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            try
            {
                m.assg_id = Request.Params["assg_id"].ToString().Trim();
                if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                {
                    m.item_id = Convert.ToUInt32(Request.Params["item_id"].ToString().Trim());
                }
                if (_iasdMgr.GetCountByItem(m) == 0)
                {
                    json = "{success:true,totalCount:" + 0 + ",msg:1,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回json數據     
                }
                else
                {
                    list = _iasdMgr.GetAseldListByItemid(m);
                    foreach (var item in list)
                    {
                        m.seld_id = item.seld_id;
                    }
                    m.wust_id = "BSY";
                    m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    _iasdMgr.Updwust(m);
                    json = "{success:true,totalCount:" + list.Count + ",msg:0,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }
Пример #5
0
        public void OutUndoneJobExl()
        {
            string type = string.Empty;
            AseldQuery asd = new AseldQuery();
            DataTable dt = new DataTable();
            StringBuilder sbJobsNumber = new StringBuilder();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            try
            {
                //選擇製作總表,還是產生明細報表
                if (Request.Params["radio1"] == "true")
                {
                    type = "0";
                }
                if (Request.Params["radio2"] == "true")
                {
                    type = "1";
                    if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
                    {
                        //asd.assg_id = Request["assg_id"].Replace(",",",");
                        string str = Request["assg_id"].Replace(",", ",");
                        string[] strs = str.Split(',');
                        foreach (string item in strs)
                        {
                            asd.assg_id = item;
                            sbJobsNumber.AppendFormat("'{0}',", asd.assg_id);
                        }
                    }
                }
                DateTime time;
                asd.create_dtim = DateTime.MinValue;
                if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time) && Request.Params["starttime"].Substring(0, 10) != "1970-01-01")
                {

                    asd.create_dtim = DateTime.Parse(Request.Params["starttime"]).ToString("yyyy-MM-dd") == "1970-01-01" ? DateTime.MinValue : DateTime.Parse(Request.Params["starttime"]);
                }
                if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time) && Request.Params["endtime"].Substring(0, 10) != "1970-01-01")
                {
                    asd.create_dtim2 = DateTime.Parse(Request.Params["endtime"]).ToString("yyyy-MM-dd") == "1970-01-01" ? DateTime.MinValue : DateTime.Parse(Request.Params["endtime"]);
                }
                string jobNumbers = sbJobsNumber.ToString().TrimEnd(',');
                string fileName = string.Empty;
                MemoryStream ms = new MemoryStream();
                if (type == "0")
                {
                    fileName = "缺貨總報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    ms = ExcelHelperXhf.ExportDT(_iasdMgr.GetDetailOrSimple(type, jobNumbers, asd), "總表~未完成理貨工作_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
                }
                else if (type == "1")
                {
                    fileName = "缺貨明細報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    ms = ExcelHelperXhf.ExportDT(_iasdMgr.GetDetailOrSimple(type, jobNumbers, asd), "缺貨明細~未完成理貨工作_" + 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);
            }
        }
Пример #6
0
 public void ExportAseldMessage()
 {
     string json = string.Empty;
     AseldQuery m = new AseldQuery();
     if (!string.IsNullOrEmpty(Request.Params["job_id"]))
     {//料位開始
         m.assg_id = Request.Params["job_id"];
     }
     if (!string.IsNullOrEmpty(Request.Params["aseld_type"]))
     {
         m.commodity_type = Request.Params["aseld_type"];
     }
     if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
     {
         System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
     }
     DataTable dtHZ = new DataTable();
     string newExcelName = string.Empty;
     dtHZ.Columns.Add("出貨單號", typeof(String));
     dtHZ.Columns.Add("訂單編號", typeof(String));
     dtHZ.Columns.Add("料位", typeof(String));
     dtHZ.Columns.Add("數量", typeof(String));
     dtHZ.Columns.Add("已撿", typeof(String));
     dtHZ.Columns.Add("缺", typeof(String));
     dtHZ.Columns.Add("品號", typeof(String));
     dtHZ.Columns.Add("條碼", typeof(String));
     dtHZ.Columns.Add("商品名稱", typeof(String));
     dtHZ.Columns.Add("狀態", typeof(String));
     dtHZ.Columns.Add("規格", typeof(String));
     try
     {
         DataTable dt = new DataTable();
         _iasdMgr = new AseldMgr(mySqlConnectionString);
         _IiupcMgr = new IupcMgr(mySqlConnectionString);
         dt = _iasdMgr.ExportAseldMessage(m);
         foreach (DataRow item in dt.Rows)
         {
             DataRow dr = dtHZ.NewRow();
             dr[0] = item["deliver_code"];
             dr[1] = item["ord_id"];
             //dr[1] = item["sel_loc"];
             if (string.IsNullOrEmpty(item["loc_id"].ToString()))
             {
                 switch (item["commodity_type"].ToString())
                 {
                     case "2": dr[2] = "YY999999"; break;
                     case "3": dr[2] = "ZZ999999"; break;
                 }
             }
             else
             {
                 dr[2] = item["loc_id"];
             }
             dr[3] = item["out_qty"];
             dr[4] = string.Empty;
             dr[5] = string.Empty;
             dr[6] = item["item_id"];
             dr[7] = " " + _IiupcMgr.Getupc(item["item_id"].ToString(), "0");
             dr[8] = item["product_name"];
             dr[9] = item["wust_id"];
             dr[10] = item["prod_sz"];
             dtHZ.Rows.Add(dr);
         }
         string str = "撿貨報表by料位";
         if (!string.IsNullOrEmpty(m.assg_id))
         {
             if (m.assg_id.IndexOf('N') == 0)
             {
                 str = m.assg_id + "(常溫/";
             }
             else if (m.assg_id.IndexOf('N') != 0 && m.assg_id.IndexOf('F') == 0)
             {
                 str = m.assg_id + "(冷凍/";
             }
         }
         if (m.commodity_type == "2")
         {
             str = str + "寄倉)";
         }
         else if (m.commodity_type == "3")
         {
             str = str + "調度)";
         }
         string fileName = str + DateTime.Now.ToString("_yyyyMMddHHmmss") + ".xls";
         MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, str + "_" + 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:[]}";
     }
 }
Пример #7
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;
        }
Пример #8
0
        public void ExportDeliveryStatement()
        {
            string json = string.Empty;
            IlocQuery iloc = new IlocQuery();
            if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
            }
            DataTable dtHZ = new DataTable();
            string counts = Request.Params["counts"];
            string searchtype = Request.Params["searchtype"];//常溫或者冷凍
            string newExcelName = string.Empty;
            dtHZ.Columns.Add("主料位", typeof(String));
            dtHZ.Columns.Add("溫層", typeof(String));
            dtHZ.Columns.Add("品號", typeof(String));
            dtHZ.Columns.Add("品名", typeof(String));
            dtHZ.Columns.Add("規格", typeof(String));
            dtHZ.Columns.Add("廠商", typeof(String));
            dtHZ.Columns.Add("數量", typeof(String));
            dtHZ.Columns.Add("寄倉/調度", typeof(String));
            try
            {
                DataTable dt = new DataTable();
                _iasdMgr = new AseldMgr(mySqlConnectionString);
                dt = _iasdMgr.ExportDeliveryStatement(Convert.ToInt32(counts), Convert.ToInt32(searchtype));

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = dt.Rows[i]["loc_id"];

                    if (Convert.ToInt32(dt.Rows[i]["export_id"]) == 2)
                    {
                        dr[1] = "常溫";
                    }
                    else if (Convert.ToInt32(dt.Rows[i]["export_id"]) == 92)
                    {
                        dr[1] = "冷凍";
                    }
                    else
                    {
                        dr[1] = "";
                    }
                    dr[2] = dt.Rows[i]["item_id"];
                    dr[3] = dt.Rows[i]["product_name"];

                    dr[4] = dt.Rows[i]["prod_sz"];
                    dr[5] = dt.Rows[i]["vendor_name_full"];

                    dr[6] = dt.Rows[i]["buy_num"];
                    if (dt.Rows[i]["product_mode"].ToString() == "2")
                    {
                        dr[7] = "寄倉";
                    }
                    else if (dt.Rows[i]["product_mode"].ToString() == "3")
                    {
                        dr[7] = "調度";
                    }
                    else
                    {
                        dr[7] = "";
                    }
                    dtHZ.Rows.Add(dr);
                }
                if (System.IO.File.Exists(newExcelName))
                {
                    System.IO.File.Delete(newExcelName);
                }
                string fileName = DateTime.Now.ToString("大出貨報表_yyyyMMddHHmm") + ".xls";
                MemoryStream ms = new MemoryStream();
                if (searchtype == "2")
                {
                    ms = ExcelHelperXhf.ExportDT(dtHZ, "常溫~大出貨報表_" + DateTime.Now.ToString("yyyyMMddHHmm"));
                }
                else
                {
                    ms = ExcelHelperXhf.ExportDT(dtHZ, "冷凍~大出貨報表_" + DateTime.Now.ToString("yyyyMMddHHmm"));
                }
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(ms.ToArray());
                //CsvHelper.ExportDataTableToCsv(dtHZ, newExcelName, colname, 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,data:[]}";
            }
        }
Пример #9
0
 //理貨員工作--寄倉--獲取商品數據
 public HttpResponseBase JudgeAssg()
 {//判斷寄倉或者調度
     string json = String.Empty;
     string id = Request.Params["assg_id"];
     Aseld m = new Aseld();
     List<AseldQuery> list = new List<AseldQuery>();
     _iasdMgr = new AseldMgr(mySqlConnectionString);
     try
     {
         if (id.Length > 9)
         {//獲取寄倉信息
             m.assg_id = id;
             list = _iasdMgr.GetAseldList(m);
             foreach (var item in list)
             {
                 m.seld_id = item.seld_id;
             }
             m.wust_id = "BSY";
             m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
             _iasdMgr.Updwust(m);
         }
         json = "{success:true,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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,msg:0}";
     }
     this.Response.Clear();
     this.Response.Write(json.ToString());
     this.Response.End();
     return this.Response;
 }
Пример #10
0
 public HttpResponseBase Getfreight()
 {
     string json = string.Empty;
     Aseld q = new Aseld();
     string fre;
     try
     {
         _iasdMgr = new AseldMgr(mySqlConnectionString);
         if (!String.IsNullOrEmpty(Request.Params["number"]))//如果是新增
         {
             q.ord_id = Convert.ToInt32(Request.Params["number"]);
         }
         fre = _iasdMgr.Getfreight(q.ord_id.ToString());
         if (!string.IsNullOrEmpty(fre))
         {
             fre = fre.Substring(0, 1);
         }
         json = "{success:true,fre:'" + fre + "'}";//返回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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Пример #11
0
        //生成理货单
        public HttpResponseBase CreateTallyList()
        {
            string json = String.Empty;
            Aseld m = new Aseld();
            AseldMaster am = new AseldMaster();
            StringBuilder sql = new StringBuilder();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            _aseldmasterMgr = new AseldMasterMgr(mySqlConnectionString);

            //string order_id = Request.Params["order_id"];
            string deliver_id = Request.Params["deliver_id"];
            string fre = Request.Params["type_id"];
            int radioselect = Convert.ToInt32(Request.Params["radio"]);

            //string ticket = "";
            if (deliver_id != "" && fre != "")
            {
                DateTime dt = DateTime.Now;
                string type_id = "N";
                if (fre != "2" && fre == "92")
                {
                    type_id = "F";
                }
                string assg = type_id + dt.ToString("yyyyMMddHHmmss");
                try
                {
                    if (!string.IsNullOrEmpty(deliver_id))
                    {
                        deliver_id = deliver_id.Substring(0, deliver_id.Length - 1).ToString();
                        DataTable selDT = _iasdMgr.SelOrderDetail(deliver_id, fre, radioselect);

                        foreach (DataRow r in selDT.Rows)
                        {
                            m.ordd_id = Convert.ToInt32(r["detail_id"]);
                            _iasdMgr.ConsoleAseldBeforeInsert(Convert.ToInt32(r["detail_id"]));
                            //ticket = ticket + item.ticket_id.ToString() + ',';

                            m.deliver_id = Convert.ToInt32(r["deliver_id"]);

                            m.deliver_code = CreateDeliverCode(r["deliver_id"].ToString());

                            m.ord_id = Int32.Parse(r["order_id"].ToString());//order_id
                            m.ordd_id = Int32.Parse(r["detail_id"].ToString());//od.detail_id
                            m.cust_id = r["user_id"].ToString();//om.user_id
                            m.hzd_ind = r["item_id"].ToString(); //od.item_id
                            m.item_id = Convert.ToUInt32(r["item_id"]);//od.item_id
                            m.assg_id = assg;
                            m.prod_qty = Int32.Parse(r["buy_num"].ToString());
                            if (r["sel_loc"].ToString() == "YY999999")
                            {
                                m.sel_loc = null;
                            }
                            else
                            {
                                m.sel_loc = r["sel_loc"].ToString();// i.loc_id
                            }
                            m.curr_pal_no = int.Parse(r["order_id"].ToString() + "1");//om.order_id
                            m.wust_id = "AVL";
                            m.description = Convert.ToString(r["description"]);//od.product_name
                            m.prod_sz = r["prod_sz"].ToString();//od.product_spec_name
                            m.cust_name = r["cust_name"].ToString();//om.delivery_name
                            m.invc_id = int.Parse(r["order_id"].ToString());//om.order_id
                            m.commodity_type = r["product_mode"].ToString();//2寄倉或者3調度
                            //if (m.commodity_type == "3")
                            //{
                            //    m.sel_loc = "ZZ999999";
                            //}
                            if (Convert.ToInt32(r["item_mode"]) != 0 && Convert.ToInt32(r["parent_num"]) != 0)
                            {
                                m.out_qty = m.prod_qty * Int32.Parse(r["parent_num"].ToString());
                                m.ord_qty = m.out_qty;
                            }
                            else
                            {
                                m.out_qty = m.prod_qty;
                                m.ord_qty = m.out_qty;
                            }
                            m.upc_id = r["upc_id"].ToString();//iu.upc_id
                            m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                            sql.Append(_iasdMgr.Insert(m));//add aseld sql
                        }
                        am.assg_id = assg;
                        am.create_time = dt;
                        am.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                        sql.AppendFormat(_aseldmasterMgr.Insert(am));//add aseld sql
                        sql.AppendFormat(_iasdMgr.UpdTicker(deliver_id));//upd deliver_id 

                        int msg = _iasdMgr.InsertSql(sql.ToString());
                        if (msg > 0)
                        {
                            json = "{success:true,assg:'" + assg + "'}";
                        }
                        else
                        {
                            json = "{success:false,msg:0}";
                        }
                    }
                    else
                    {
                        json = "{success:false,msg:0}";
                    }
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                    json = "{success:false,msg:0}";
                }
            }
            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }
Пример #12
0
        //理貨列表
        public HttpResponseBase GetAseldList()
        {
            string json = string.Empty;
            OrderMasterQuery oderMaster = new OrderMasterQuery();
            oderMaster.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
            oderMaster.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["type_id"]))//判斷id是不是存在.也就是說是否選擇了運送方式.當id不為0時表示選擇了運送方式.
                {

                    List<OrderMasterQuery> store = new List<OrderMasterQuery>();
                    List<OrderMasterQuery> storetwo = new List<OrderMasterQuery>();
                    _iasdMgr = new AseldMgr(mySqlConnectionString);
                    int totalCount = 0;
                    oderMaster.export_id = Convert.ToInt32(Request.Params["type_id"]);
                    if (!string.IsNullOrEmpty(Request.Params["deliver_type"]))
                    {
                        oderMaster.deliver_type = Convert.ToInt32(Request.Params["deliver_type"]);
                    }
                    string i = Request.Params["beforeradio"];
                    if (i == "false" || i == "true")
                    {
                        if (i == "false")//有調度
                        {
                            oderMaster.jdtype = 2;
                        }
                        else if (i == "true")//表示無調度
                        {
                            oderMaster.jdtype = 1;
                        }
                    }
                    else
                    {
                        oderMaster.jdtype = Convert.ToInt32(Request.Params["radio"]);//1 表示沒有調度 2 表示有調度
                    }
                    store = _iasdMgr.GetOrderMasterList(oderMaster, out  totalCount);
                    foreach (var item in store)
                    {
                        oderMaster.deliver_id = item.deliver_id;
                        storetwo = _iasdMgr.GetAllOrderDetail(oderMaster);
                        int count = 0;//寄倉品類數量
                        int dcount = 0;//調度品類數量
                        foreach (var items in storetwo)
                        {
                            //參數表 1 自出 2 寄倉 3 調度
                            if (items.product_mode == 2)
                            {
                                count = count + 1;
                                item.count = count;
                            }
                            else if (items.product_mode == 3)
                            {
                                dcount = dcount + 1;
                                item.dcount = dcount;
                            }
                        }
                        //oderMaster.Order_Id = item.Order_Id;
                        //storetwo = _iasdMgr.GetAllOrderDetail(oderMaster);
                        //int count = 0;//寄倉品類數量
                        //int dcount = 0;//調度品類數量
                        //foreach (var items in storetwo)
                        //{
                        //    //參數表 1 自出 2 寄倉 3 調度
                        //    if (items.product_mode == 2)
                        //    {
                        //        count = count + 1;
                        //        item.count = count;
                        //    }
                        //    else if (items.product_mode == 3)
                        //    {
                        //        dcount = dcount + 1;
                        //        item.dcount = dcount;
                        //    }
                        //}
                    }
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                    //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                    timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
                }
                else
                {
                    json = "{success:false,totalCount:0,data:[]}";//返回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;
        }
Пример #13
0
        // 變更數量--丟棄
        public HttpResponseBase UpdProdqty()
        {
            Iinvd m = new Iinvd();
            IinvdLog il = new IinvdLog();
            _iinvd = new IinvdMgr(mySqlConnectionString);
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            try
            {
                il.nvd_id = Int32.Parse(Request.Params["row_id"].ToString());
                il.change_num = Int32.Parse(Request.Params["change_num"].ToString());
                il.from_num = Int32.Parse(Request.Params["from_num"].ToString());
                il.create_user = (Session["caller"] as Caller).user_id;
                il.create_date = DateTime.Now;

                m.row_id = il.nvd_id;
                m.prod_qty = il.change_num + il.from_num;
                m.change_dtim = DateTime.Now;
                m.change_user = (Session["caller"] as Caller).user_id;
                if (m.prod_qty >= 0)
                {
                    sb.Append(_iinvd.UpdProdqty(m));
                    sb.Append(_iinvd.InsertIinvdLog(il));
                    _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    jsonStr = "{success:true,msg:0}";
                }
                else
                {
                    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;
        }