Пример #1
0
 public HttpResponseBase GetVendorName()
 {
     _IiplasMgr = new IplasMgr(mySqlConnectionString);
     List<Vendor> stores = new List<Vendor>();
     string json = string.Empty;
     try
     {
         Vendor query = new Vendor();
         string sql = string.Empty;
         if (!string.IsNullOrEmpty(Request.Params["type"]))
         {
             sql = "";
         }
         else
         {
             sql = " and assist = 1 ";
         }
         stores = _IiplasMgr.VendorQueryAll(query, sql);
         json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回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:true,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Пример #2
0
 public void NoIlocReportList()
 {
     string json = string.Empty;
     string fileName = "無主料位商品報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
     ProductQuery prod = new ProductQuery();
     prod.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
     prod.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["search"]))
         {
             prod.vendor_name_simple = Request.Params["search"];
         }
         DataTable dt = new DataTable();
         _IiplasMgr = new IplasMgr(mySqlConnectionString);
         _IiupcMgr = new IupcMgr(mySqlConnectionString);
         dt = _IiplasMgr.NoIlocReportList(prod);
         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));
         // pe.inner_pack_len,pe.inner_pack_wid,pe.inner_pack_hgt
         foreach (DataRow item in dt.Rows)
         {
             DataRow dr = dtHZ.NewRow();
             dr[0] = item["loc_id"];
             dr[1] = item["Product_Id"];
             dr[2] = item["item_id"];
             dr[3] = item["Product_Name"];
             dr[4] = GetProductSpec(item["item_id"].ToString());
             dr[5] = item["vendor_name_simple"];
             if (string.IsNullOrEmpty(_IiupcMgr.Getupc(item["item_id"].ToString(), "0")))
             {
                 dr[6] = "未維護";
             }
             else
             {
                 dr[6] = " " + _IiupcMgr.Getupc(item["item_id"].ToString(), "0");
             }
             if (string.IsNullOrEmpty(item["inner_pack_len"].ToString()))
             {
                 dr[7] = "未維護";
             }
             else
             {
                 dr[7] = item["inner_pack_len"];
             }
             if (string.IsNullOrEmpty(item["inner_pack_wid"].ToString()))
             {
                 dr[8] = "未維護";
             }
             else
             {
                 dr[8] = item["inner_pack_wid"];
             }
             if (string.IsNullOrEmpty(item["inner_pack_hgt"].ToString()))
             {
                 dr[9] = "未維護";
             }
             else
             {
                 dr[9] = item["inner_pack_hgt"];
             }
             dtHZ.Rows.Add(dr);
         }
         MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "無主料位商品報表(寄倉品)" + "_" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
         Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
         Response.BinaryWrite(ms.ToArray());
         #region CSV
         //string[] colname = new string[dtHZ.Columns.Count];
         //string filename = "NoIplas.csv";
         //newExcelName = Server.MapPath(excelPath) + filename;
         //for (int i = 0; i < dtHZ.Columns.Count; i++)
         //{
         //    colname[i] = dtHZ.Columns[i].ColumnName;
         //}
         //if (System.IO.File.Exists(newExcelName))
         //{
         //    System.IO.File.Delete(newExcelName);
         //}
         //CsvHelper.ExportDataTableToCsv(dtHZ, newExcelName, colname, true);
         //IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         #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,data:[]}";
     }
 }
Пример #3
0
        public HttpResponseBase IlocUploadExcel()
        {
            string newName = string.Empty;
            string json = string.Empty;
            List<IlocQuery> store = new List<IlocQuery>();
            HashEncrypt hashpt = new HashEncrypt();
            try
            {

                DTIlocExcel.Clear();
                DTIlocExcel.Columns.Clear();
                DTIlocExcel.Columns.Add("料位編號", typeof(String));
                DTIlocExcel.Columns.Add("料位類型", typeof(String));
                DTIlocExcel.Columns.Add("所在層數");
                DTIlocExcel.Columns.Add("不能匯入的原因", typeof(String));
                int result = 0;
                int count = 0;//總匯入數
                int entercount = 0;//插入失敗個數
                int errorcount = 0;//數據異常個數
                int create_user = (Session["caller"] as Caller).user_id;
                if (Request.Files["ImportExcelFile"] != null && Request.Files["ImportExcelFile"].ContentLength > 0)
                {
                    HttpPostedFileBase excelFile = Request.Files["ImportExcelFile"];
                    newName = Server.MapPath(excelPath) + excelFile.FileName;
                    excelFile.SaveAs(newName);
                    DataTable dt = new DataTable();
                    NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newName);
                    dt = helper.SheetData();
                    if (dt.Rows.Count > 0)
                    {
                        _IlocMgr = new IlocMgr(mySqlConnectionString);
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);

                        int i = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
                            StringBuilder strsql = new StringBuilder();
                            Iloc ic = new BLL.gigade.Model.Iloc();
                            i++;
                            try
                            {
                                if (!string.IsNullOrEmpty(dr[0].ToString()) && Regex.IsMatch(dr[0].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$") && !string.IsNullOrEmpty(dr[1].ToString()) && (dr[1].ToString() == "S" || dr[1].ToString() == "R"))
                                {
                                    int loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[0].ToString());//判斷料位是否存在
                                    ic.loc_id = dr[0].ToString();
                                    ic.lsta_id = "F";
                                    ic.lcat_id = dr[1].ToString();
                                    ic.create_dtim = DateTime.Now;
                                    ic.change_dtim = DateTime.Now;
                                    ic.create_user = create_user;
                                    ic.change_user = create_user;
                                    ic.loc_status = 1;
                                    ic.lev = GetIntByString(dr[2].ToString());
                                    if (loc_id_exsit > 0)
                                    {
                                        DataRow drtwo = DTIlocExcel.NewRow();
                                        drtwo[0] = dr[0].ToString();
                                        drtwo[1] = dr[1].ToString();
                                        drtwo[2] = dr[2].ToString();
                                        drtwo[3] = "該料位已存在";
                                        DTIlocExcel.Rows.Add(drtwo);
                                        errorcount++;
                                        continue;
                                    }
                                    else//料位不存在
                                    {
                                        string has = hashpt.Md5Encrypt(ic.loc_id, "16");

                                        strsql.AppendFormat(@"insert into iloc(dc_id,whse_id,loc_id,llts_id,bkfill_loc,ldes_id,
                                             ldim_id,x_coord,y_coord,z_coord,bkfill_x_coord,bkfill_y_coord,
                                             bkfill_z_coord,lsta_id,sel_stk_pos,sel_seq_loc,sel_pos_hgt,rsv_stk_pos,
                                             rsv_pos_hgt,stk_lmt,stk_pos_wid,lev,lhnd_id,ldsp_id,
                                             create_user,create_dtim,comingle_allow,change_user,change_dtim,lcat_id,
                                             space_remain,max_loc_wgt,loc_status,stk_pos_dep,hash_loc_id
                    ) values ('{0}','{1}','{2}','{3}','{4}','{5}',
                              '{6}','{7}','{8}','{9}','{10}','{11}',
                              '{12}','{13}','{14}','{15}','{16}','{17}',
                              '{18}','{19}','{20}','{21}','{22}','{23}',
                              '{24}','{25}','{26}','{27}','{28}','{29}',
                              '{30}','{31}','{32}','{33}','{34}');",
                             ic.dc_id, ic.whse_id, ic.loc_id, ic.llts_id, ic.bkfill_loc, ic.ldes_id,
                             ic.ldim_id, ic.x_coord, ic.y_coord, ic.z_coord, ic.bkfill_x_coord, ic.bkfill_y_coord,
                             ic.bkfill_z_coord, ic.lsta_id, ic.sel_stk_pos, ic.sel_seq_loc, ic.sel_pos_hgt, ic.rsv_stk_pos,
                             ic.rsv_pos_hgt, ic.stk_lmt, ic.stk_pos_wid, ic.lev, ic.lhnd_id, ic.ldsp_id,
                             ic.create_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.create_dtim), ic.comingle_allow, ic.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.change_dtim), ic.lcat_id,
                             ic.space_remain, ic.max_loc_wgt, ic.loc_status, ic.stk_pos_dep, has
                             );
                                        result = _IlocMgr.SaveBySql(strsql.ToString());
                                        if (result > 0)
                                        {
                                            count++;
                                            continue;
                                        }
                                        else
                                        {
                                            DataRow drtwo = DTIlocExcel.NewRow();
                                            drtwo[0] = dr[0].ToString();
                                            drtwo[1] = dr[1].ToString();
                                            drtwo[2] = dr[2].ToString();
                                            drtwo[3] = "料位插入數據庫時失敗";
                                            DTIlocExcel.Rows.Add(drtwo);
                                            entercount++;
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    DataRow drtwo = DTIlocExcel.NewRow();
                                    drtwo[0] = dr[0].ToString();
                                    drtwo[1] = dr[1].ToString();
                                    drtwo[2] = dr[2].ToString();
                                    drtwo[3] = "料位編號或者料位類型或者所在層數不符合格式";
                                    DTIlocExcel.Rows.Add(drtwo);
                                    errorcount++;
                                    continue;
                                }
                            }
                            catch
                            {
                                DataRow drtwo = DTIlocExcel.NewRow();
                                drtwo[0] = dr[0].ToString();
                                drtwo[1] = dr[1].ToString();
                                drtwo[2] = dr[2].ToString();
                                drtwo[3] = "數據異常";
                                DTIlocExcel.Rows.Add(drtwo);
                                errorcount++;
                                continue;
                            }
                        }
                        if (count > 0)
                        {
                            json = "{success:true,total:" + count + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                        else
                        {
                            json = "{success:true,total:" + 0 + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                    }
                    else
                    {
                        json = "{success:true,total:" + 0 + ",error:" + 0 + ",entercount" + 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,data:" + "" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #4
0
        // 廠商下拉列表
        public HttpResponseBase GetVendorName()
        {
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            List<Vendor> stores = new List<Vendor>();
            string json = string.Empty;
            try
            {
                Vendor query = new Vendor();
                stores = _IiplasMgr.VendorQueryAll(query);

                query.vendor_name_simple = "所有廠商名稱";
                stores.Insert(0, query);
                json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回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:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #5
0
 public void GetIlocReportList()
 {
     string json = string.Empty;
     string fileName = "主料位商品摘除報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
     ProductQuery prod = new ProductQuery();
     prod.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
     prod.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["search"]))
         {
             prod.vendor_name_simple = Request.Params["search"];
         }
         _IiplasMgr = new IplasMgr(mySqlConnectionString);
         int totalCount = 0;
         DataTable store = _IiplasMgr.GetIlocReportList(prod, out  totalCount);
         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));
         foreach (DataRow item in store.Rows)
         {
             DataRow dr = dtHZ.NewRow();
             dr[0] = item["loc_id"];
             dr[1] = item["product_id"];
             dr[2] = item["item_id"];
             dr[3] = item["Product_Name"];
             dr[4] = item["prod_sz"];
             dr[5] = item["vendor_name_simple"];
             dr[6] = " " + item["upc_id"];
             dr[7] = item["parameterName"];
             dr[8] = item["product_qty"];
             dtHZ.Rows.Add(dr);
         }
         MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "主料位商品摘除報表" + "_" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
         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:[]}";
     }
 }
Пример #6
0
        //商品指定主料位-互搬
        public HttpResponseBase IplasUploadExcelEnter()
        {
            string newName = string.Empty;
            string json = string.Empty;
            List<IplasQuery> store = new List<IplasQuery>();
            try
            {

                DTIplasEnterExcel.Clear();
                DTIplasEnterExcel.Columns.Clear();

                DTIplasEnterExcel.Columns.Add("商品細項編號", typeof(String));
                DTIplasEnterExcel.Columns.Add("原料位", typeof(String));
                DTIplasEnterExcel.Columns.Add("新料位", typeof(String));
                DTIplasEnterExcel.Columns.Add("不能搬移的原因", typeof(String));
                int result = 0;
                int count = 0;//總匯入數
                int errorcount = 0;//數據異常個數
                int comtentcount = 0;//內容不符合格式
                int create_user = (Session["caller"] as Caller).user_id;
                int item_idcount = 0;//商品細項編號不存在
                int item_id_have_locid = 0;//商品細項編號已存在主料位
                int locid_lock = 0;//商品料位已經被鎖定
                StringBuilder strsql = new StringBuilder();
                if (Request.Files["IplasImportExcelFile"] != null && Request.Files["IplasImportExcelFile"].ContentLength > 0)
                {
                    HttpPostedFileBase excelFile = Request.Files["IplasImportExcelFile"];
                    //FileManagement fileManagement = new FileManagement();
                    newName = Server.MapPath(excelPath) + excelFile.FileName;
                    excelFile.SaveAs(newName);
                    DataTable dt = new DataTable();
                    NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newName);
                    dt = helper.SheetData();

                    if (dt.Rows.Count > 0)
                    {
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);



                        #region 測試
                        #region 循環Excel的數據
                        Iloc ic = new BLL.gigade.Model.Iloc();
                        Iplas ips = new Iplas();
                        int i = 0;
                        if (dt.Columns.Count < 3)
                        {
                            DataRow drtwo = DTIplasEnterExcel.NewRow();
                            drtwo[0] = "這個是商品細項編號";
                            drtwo[1] = "這個是商品原料位";
                            drtwo[2] = "這個是商品新料位";
                            drtwo[3] = "請匯入足夠的列數";
                            DTIplasEnterExcel.Rows.Add(drtwo);
                            errorcount++;
                        }
                        else
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                if (string.IsNullOrEmpty(dr[0].ToString()) && string.IsNullOrEmpty(dr[1].ToString()) && string.IsNullOrEmpty(dr[2].ToString()))
                                {
                                    continue;
                                }

                                i++;
                                try
                                {
                                    if (!string.IsNullOrEmpty(dr[0].ToString()) && Regex.IsMatch(dr[0].ToString(), @"^\d{6}$") && !string.IsNullOrEmpty(dr[1].ToString()) && Regex.IsMatch(dr[1].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$") && !string.IsNullOrEmpty(dr[2].ToString()) && Regex.IsMatch(dr[2].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$"))
                                    {
                                        ic.loc_id = dr[2].ToString();
                                        //ic.lsta_id = "F";
                                        //ic.lcat_id = "S";
                                        //ic.create_dtim = DateTime.Now;
                                        //ic.change_dtim = DateTime.Now;
                                        //ic.create_user = 2;
                                        //ic.change_user = 2;
                                        //ic.loc_status = 1;
                                        ips.item_id = Convert.ToUInt32(dr[0]);
                                        ips.loc_id = dr[1].ToString();


                                        //根據商品編號查看是否存在主料位
                                        int item_id_exsit = _IiplasMgr.YesOrNoExist(Convert.ToInt32(dr[0]));//檢查item_id是否存在
                                        int loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[1].ToString());//判斷原料位是否存在
                                        int item_loc_id = _IiplasMgr.YesOrNoLocIdExsit(Convert.ToInt32(dr[0]), dr[1].ToString());//判斷原料位是否為該商品的主料位
                                        int New_loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[2].ToString());//判斷新料位是否存在
                                        int loc_id_lock = _IiplasMgr.GetLocCount(ic);//判斷新料位是否鎖定

                                        if (_IiplasMgr.IsTrue(ips) == "false")//首先判斷item_id是否存在
                                        {
                                            DataRow drtwo = DTIplasEnterExcel.NewRow();
                                            drtwo[0] = dr[0].ToString();
                                            drtwo[1] = dr[1].ToString();
                                            drtwo[2] = dr[2].ToString();
                                            drtwo[3] = "商品細項編號不存在";
                                            DTIplasEnterExcel.Rows.Add(drtwo);
                                            errorcount++;
                                            item_idcount++;
                                            continue;
                                        }
                                        else//如果存在item_id
                                        {
                                            if (loc_id_exsit <= 0)//表示原料為不存在料位//------------------------------
                                            {
                                                DataRow drtwo = DTIplasEnterExcel.NewRow();
                                                drtwo[0] = dr[0].ToString();
                                                drtwo[1] = dr[1].ToString();
                                                drtwo[2] = dr[2].ToString();
                                                drtwo[3] = "商品原料位不存在";
                                                DTIplasEnterExcel.Rows.Add(drtwo);
                                                errorcount++;
                                                locid_lock++;
                                                continue;
                                            }
                                            if (item_loc_id <= 0)//表示原料位不是此商品的原料位//------------------------------
                                            {
                                                DataRow drtwo = DTIplasEnterExcel.NewRow();
                                                drtwo[0] = dr[0].ToString();
                                                drtwo[1] = dr[1].ToString();
                                                drtwo[2] = dr[2].ToString();
                                                drtwo[3] = "原料位不是此商品的料位";
                                                DTIplasEnterExcel.Rows.Add(drtwo);
                                                errorcount++;
                                                locid_lock++;
                                                continue;
                                            }
                                            if (New_loc_id_exsit <= 0)//表示新料位不存在//------------------------------
                                            {
                                                DataRow drtwo = DTIplasEnterExcel.NewRow();
                                                drtwo[0] = dr[0].ToString();
                                                drtwo[1] = dr[1].ToString();
                                                drtwo[2] = dr[2].ToString();
                                                drtwo[3] = "新料位不存在";
                                                DTIplasEnterExcel.Rows.Add(drtwo);
                                                errorcount++;
                                                item_id_have_locid++;
                                                continue;
                                            }
                                            else
                                            {
                                                if (loc_id_lock > 0)//如果新料位存在並且沒有被鎖定--plas新增,iloc更改狀態
                                                {

                                                    ips = _IiplasMgr.getplas(ips);
                                                    ips.loc_id = dr[2].ToString();
                                                    ips.change_user = (Session["caller"] as Caller).user_id;
                                                    ips.change_dtim = DateTime.Now;
                                                    ips.item_id = Convert.ToUInt32(dr[0]);
                                                    if (_IiplasMgr.UpIplas(ips) > 0)
                                                    {
                                                        strsql.Append(ips.loc_id);

                                                        //strsql.AppendFormat("Insert into iplas (dc_id,whse_id,loc_id,change_dtim,change_user,create_dtim,create_user,lcus_id,luis_id,item_id,prdd_id,loc_rpln_lvl_uoi,loc_stor_cse_cap,ptwy_anch,flthru_anch,pwy_loc_cntl) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", ips.dc_id, ips.whse_id, ips.loc_id.ToString().ToUpper(), CommonFunction.DateTimeToString(ips.change_dtim), ips.change_user, CommonFunction.DateTimeToString(ips.create_dtim), ips.create_user, ips.lcus_id, ips.luis_id, ips.item_id, ips.prdd_id, ips.loc_rpln_lvl_uoi, ips.loc_stor_cse_cap, ips.ptwy_anch, ips.flthru_anch, ips.pwy_loc_cntl);//插入數據到表iplas表中
                                                        //strsql.AppendFormat(@" set sql_safe_updates = 0; update iloc set lsta_id='{0}',change_user='******',change_dtim='{2}' where loc_id='{3}';set sql_safe_updates = 1; ", "A", ips.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ips.change_dtim), ips.loc_id.ToString().ToUpper());
                                                        count++;
                                                        result++;
                                                    }
                                                    else
                                                    {
                                                        DataRow drtwo = DTIplasEnterExcel.NewRow();
                                                        drtwo[0] = dr[0].ToString();
                                                        drtwo[1] = dr[1].ToString();
                                                        drtwo[2] = dr[2].ToString();
                                                        drtwo[3] = "未知原因導入失敗";
                                                        DTIplasEnterExcel.Rows.Add(drtwo);
                                                        errorcount++;
                                                        continue;
                                                    }
                                                }
                                                else
                                                {
                                                    DataRow drtwo = DTIplasEnterExcel.NewRow();
                                                    drtwo[0] = dr[0].ToString();
                                                    drtwo[1] = dr[1].ToString();
                                                    drtwo[2] = dr[2].ToString();
                                                    drtwo[3] = "新料位已經被鎖定或非主料位";
                                                    DTIplasEnterExcel.Rows.Add(drtwo);
                                                    errorcount++;
                                                    item_id_have_locid++;
                                                    continue;
                                                }
                                            }


                                        }
                                    }
                                    else
                                    {
                                        DataRow drtwo = DTIplasEnterExcel.NewRow();
                                        drtwo[0] = dr[0].ToString();
                                        drtwo[1] = dr[1].ToString();
                                        drtwo[2] = dr[2].ToString();
                                        drtwo[3] = "商品細項編號或者料位不符合格式";
                                        DTIplasEnterExcel.Rows.Add(drtwo);
                                        errorcount++;
                                        comtentcount++;
                                        continue;
                                    }
                                }
                                catch
                                {
                                    DataRow drtwo = DTIplasEnterExcel.NewRow();
                                    drtwo[0] = dr[0].ToString();
                                    drtwo[1] = dr[1].ToString();
                                    drtwo[2] = dr[2].ToString();
                                    drtwo[3] = "數據異常";
                                    DTIplasEnterExcel.Rows.Add(drtwo);
                                    errorcount++;
                                    continue;
                                }
                            }
                        }
                        #endregion


                        #endregion

                        if (strsql.ToString().Trim() != "")
                        {
                            //result = _IiplasMgr.ExcelImportIplas(strsql.ToString());
                            if (result > 0)
                            {
                                json = "{success:true,total:" + count + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                            }
                            else
                            {
                                json = "{success:false}";
                            }
                        }
                        else
                        {
                            json = "{success:true,total:" + 0 + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                        }
                    }
                    else
                    {
                        json = "{success:true,total:" + 0 + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                    }
                }
            }
            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:" + "" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #7
0
        public void ExportInoiupc()
        {
            string json = string.Empty;
            IplasQuery m = new IplasQuery();
            if (!string.IsNullOrEmpty(Request.Params["startIloc"]))
            {//料位開始
                m.startloc = Request.Params["startIloc"].ToUpper();
            }
            if (!string.IsNullOrEmpty(Request.Params["endIloc"]))
            {
                m.endloc = Request.Params["endIloc"] + "Z";
                m.endloc = m.endloc.ToUpper();
            }
            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));
            try
            {
                //List<IplasQuery> store = new List<IplasQuery>();
                DataTable _dt = new DataTable();
                _IiplasMgr = new IplasMgr(mySqlConnectionString);

                //store = _IiplasMgr.Export(m);
                _dt = _IiplasMgr.ExportMessage(m);
                foreach (DataRow Drow in _dt.Rows)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = Drow["loc_id"];
                    dr[1] = Drow["lcat_id"];
                    dr[2] = Drow["item_id"];
                    dr[3] = Drow["prod_qtys"];
                    dr[4] = Drow["product_name"];
                    dr[5] = Drow["prod_sz"];
                    dr[6] = " " + Drow["upc_id"];
                    if (Drow["cde_dt"].ToString() != null && Drow["cde_dt"].ToString().Trim() != "")
                    {
                        dr[7] = DateTime.Parse(Drow["cde_dt"].ToString()).ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        dr[7] = "";
                    }
                    dtHZ.Rows.Add(dr);
                }
                string fileName = DateTime.Now.ToString("無條碼商品報表_yyyyMMddHHmm") + ".xls";
                MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "無條碼商品報表_" + DateTime.Now.ToString("yyyyMMddHHmm"));
                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:[]}";
            }
        }
Пример #8
0
        public HttpResponseBase IplasUploadExcel()
        {
            string newName = string.Empty;
            string json = string.Empty;
            List<IplasQuery> store = new List<IplasQuery>();
            try
            {

                DTIplasExcel.Clear();
                DTIplasExcel.Columns.Clear();

                DTIplasExcel.Columns.Add("商品細項編號", typeof(String));
                DTIplasExcel.Columns.Add("主料位", typeof(String));
                DTIplasExcel.Columns.Add("不能匯入的原因", typeof(String));
                int result = 0;
                int count = 0;//總匯入數
                int errorcount = 0;//數據異常個數
                int comtentcount = 0;//內容不符合格式
                int create_user = (Session["caller"] as Caller).user_id;
                int item_idcount = 0;//商品細項編號不存在
                int item_id_have_locid = 0;//商品細項編號已存在主料位
                int locid_lock = 0;//商品料位已經被鎖定
                StringBuilder strsql = new StringBuilder();
                if (Request.Files["ImportExcelFile"] != null && Request.Files["ImportExcelFile"].ContentLength > 0)
                {
                    HttpPostedFileBase excelFile = Request.Files["ImportExcelFile"];
                    //FileManagement fileManagement = new FileManagement();
                    newName = Server.MapPath(excelPath) + excelFile.FileName;
                    excelFile.SaveAs(newName);
                    DataTable dt = new DataTable();
                    NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newName);
                    dt = helper.SheetData();
                    if (dt.Rows.Count > 0)
                    {
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);
                        #region 循環Excel的數據
                        Iloc ic = new BLL.gigade.Model.Iloc();
                        Iplas ips = new Iplas();
                        int i = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
                            i++;
                            try
                            {
                                if (!string.IsNullOrEmpty(dr[0].ToString()) && Regex.IsMatch(dr[0].ToString(), @"^\d{6}$") && !string.IsNullOrEmpty(dr[1].ToString()) && Regex.IsMatch(dr[1].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$"))
                                {
                                    ic.loc_id = dr[1].ToString();
                                    ic.lsta_id = "F";
                                    ic.lcat_id = "S";
                                    ic.create_dtim = DateTime.Now;
                                    ic.change_dtim = DateTime.Now;
                                    ic.create_user = create_user;
                                    ic.change_user = create_user;
                                    ic.loc_status = 1;
                                    ips.item_id = Convert.ToUInt32(dr[0]);
                                    ips.loc_id = dr[1].ToString();
                                    ips.change_user = create_user;
                                    ips.create_user = create_user;
                                    ips.create_dtim = DateTime.Now;
                                    ips.change_dtim = DateTime.Now;
                                    //根據商品編號查看是否存在主料位
                                    int item_id_exsit = _IiplasMgr.YesOrNoExist(Convert.ToInt32(dr[0]));//檢查item_id是否存在主料位
                                    int loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[1].ToString());//判斷料位是否存在
                                    int loc_id_lock = _IiplasMgr.GetLocCount(ic);//判斷料位是否鎖定
                                    if (_IiplasMgr.IsTrue(ips) == "false")//首先判斷item_id是否存在
                                    {
                                        DataRow drtwo = DTIplasExcel.NewRow();
                                        drtwo[0] = dr[0].ToString();
                                        drtwo[1] = dr[1].ToString();
                                        drtwo[2] = "商品細項編號不存在";
                                        DTIplasExcel.Rows.Add(drtwo);
                                        errorcount++;
                                        item_idcount++;
                                        continue;
                                    }
                                    else//如果存在item_id
                                    {
                                        if (item_id_exsit > 0)//表示已經存在主料位
                                        {
                                            DataRow drtwo = DTIplasExcel.NewRow();
                                            drtwo[0] = dr[0].ToString();
                                            drtwo[1] = dr[1].ToString();
                                            drtwo[2] = "商品細項編號已存在主料位";
                                            DTIplasExcel.Rows.Add(drtwo);
                                            errorcount++;
                                            item_id_have_locid++;
                                            continue;
                                        }
                                        #region
                                        if (loc_id_exsit > 0)//如果料位存在
                                        {
                                            if (loc_id_lock > 0)//如果料位存在並且沒有被鎖定
                                            {

                                                strsql.AppendFormat("Insert into iplas (dc_id,whse_id,loc_id,change_dtim,change_user,create_dtim,create_user,lcus_id,luis_id,item_id,prdd_id,loc_rpln_lvl_uoi,loc_stor_cse_cap,ptwy_anch,flthru_anch,pwy_loc_cntl) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", ips.dc_id, ips.whse_id, ips.loc_id.ToString().ToUpper(), CommonFunction.DateTimeToString(ips.change_dtim), ips.change_user, CommonFunction.DateTimeToString(ips.create_dtim), ips.create_user, ips.lcus_id, ips.luis_id, ips.item_id, ips.prdd_id, ips.loc_rpln_lvl_uoi, ips.loc_stor_cse_cap, ips.ptwy_anch, ips.flthru_anch, ips.pwy_loc_cntl);//插入數據到表iplas表中
                                                strsql.AppendFormat(@" set sql_safe_updates = 0; update iloc set lsta_id='{0}',change_user='******',change_dtim='{2}' where loc_id='{3}';set sql_safe_updates = 1; ", "A", ips.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ips.change_dtim), ips.loc_id.ToString().ToUpper());
                                                count++;
                                            }
                                            else
                                            {
                                                DataRow drtwo = DTIplasExcel.NewRow();
                                                drtwo[0] = dr[0].ToString();
                                                drtwo[1] = dr[1].ToString();
                                                drtwo[2] = "主料位已經被鎖定";
                                                DTIplasExcel.Rows.Add(drtwo);
                                                errorcount++;
                                                locid_lock++;
                                                continue;
                                            }
                                        }
                                        else//料位不存在
                                        {
                                            strsql.AppendFormat(@"insert into iloc(dc_id,whse_id,loc_id,llts_id,bkfill_loc,ldes_id,
                                             ldim_id,x_coord,y_coord,z_coord,bkfill_x_coord,bkfill_y_coord,
                                             bkfill_z_coord,lsta_id,sel_stk_pos,sel_seq_loc,sel_pos_hgt,rsv_stk_pos,
                                             rsv_pos_hgt,stk_lmt,stk_pos_wid,lev,lhnd_id,ldsp_id,
                                             create_user,create_dtim,comingle_allow,change_user,change_dtim,lcat_id,
                                             space_remain,max_loc_wgt,loc_status,stk_pos_dep
                    ) values ('{0}','{1}','{2}','{3}','{4}','{5}',
                              '{6}','{7}','{8}','{9}','{10}','{11}',
                              '{12}','{13}','{14}','{15}','{16}','{17}',
                              '{18}','{19}','{20}','{21}','{22}','{23}',
                              '{24}','{25}','{26}','{27}','{28}','{29}',
                              '{30}','{31}','{32}','{33}');",
                                 ic.dc_id, ic.whse_id, ic.loc_id, ic.llts_id, ic.bkfill_loc, ic.ldes_id,
                                 ic.ldim_id, ic.x_coord, ic.y_coord, ic.z_coord, ic.bkfill_x_coord, ic.bkfill_y_coord,
                                 ic.bkfill_z_coord, ic.lsta_id, ic.sel_stk_pos, ic.sel_seq_loc, ic.sel_pos_hgt, ic.rsv_stk_pos,
                                 ic.rsv_pos_hgt, ic.stk_lmt, ic.stk_pos_wid, ic.lev, ic.lhnd_id, ic.ldsp_id,
                                 ic.create_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.create_dtim), ic.comingle_allow, ic.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.change_dtim), ic.lcat_id,
                                 ic.space_remain, ic.max_loc_wgt, ic.loc_status, ic.stk_pos_dep
                                 );
                                            strsql.AppendFormat("Insert into iplas (dc_id,whse_id,loc_id,change_dtim,change_user,create_dtim,create_user,lcus_id,luis_id,item_id,prdd_id,loc_rpln_lvl_uoi,loc_stor_cse_cap,ptwy_anch,flthru_anch,pwy_loc_cntl) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", ips.dc_id, ips.whse_id, ips.loc_id.ToString().ToUpper(), CommonFunction.DateTimeToString(ips.change_dtim), ips.change_user, CommonFunction.DateTimeToString(ips.create_dtim), ips.create_user, ips.lcus_id, ips.luis_id, ips.item_id, ips.prdd_id, ips.loc_rpln_lvl_uoi, ips.loc_stor_cse_cap, ips.ptwy_anch, ips.flthru_anch, ips.pwy_loc_cntl);//插入數據到表iplas表中
                                            strsql.AppendFormat(@" set sql_safe_updates = 0; update iloc set lsta_id='{0}',change_user='******',change_dtim='{2}' where loc_id='{3}';set sql_safe_updates = 1; ", "A", ips.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ips.change_dtim), ips.loc_id.ToString().ToUpper());
                                            count++;
                                        }
                                        #endregion
                                    }
                                }
                                else
                                {
                                    DataRow drtwo = DTIplasExcel.NewRow();
                                    drtwo[0] = dr[0].ToString();
                                    drtwo[1] = dr[1].ToString();
                                    drtwo[2] = "商品細項編號或者主料位不符合格式";
                                    DTIplasExcel.Rows.Add(drtwo);
                                    errorcount++;
                                    comtentcount++;
                                    continue;
                                }
                            }
                            catch
                            {
                                DataRow drtwo = DTIplasExcel.NewRow();
                                drtwo[0] = dr[0].ToString();
                                drtwo[1] = dr[1].ToString();
                                drtwo[2] = "數據異常";
                                DTIplasExcel.Rows.Add(drtwo);
                                errorcount++;
                                continue;
                            }
                        }
                        #endregion
                        if (strsql.ToString().Trim() != "")
                        {
                            result = _IiplasMgr.ExcelImportIplas(strsql.ToString());
                            if (result > 0)
                            {
                                json = "{success:true,total:" + count + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                            }
                            else
                            {
                                json = "{success:false}";
                            }
                        }
                        else
                        {
                            json = "{success:true,total:" + 0 + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                        }
                    }
                    else
                    {
                        json = "{success:true,total:" + 0 + ",error:" + errorcount + ",item_idcount:" + item_idcount + ",item_id_have_locid:" + item_id_have_locid + ",comtentcount:" + comtentcount + ",locid_lock:" + locid_lock + "}";
                    }
                }
            }
            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:" + "" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #9
0
        public void IplasExcelList()
        {
            string json = string.Empty;
            IplasQuery ilpsQuery = new IplasQuery();
            DataTable dtExcel = new DataTable();
            try
            {
                string content = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["search_type"]))
                {
                    ilpsQuery.serch_type = int.Parse(Request.Params["search_type"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcontent"]) && Request.Params["searchcontent"].Trim().Length > 0)//有查詢內容就不管時間
                    {

                        switch (ilpsQuery.serch_type)
                        {
                            case 1:
                            case 2:
                                ilpsQuery.searchcontent = 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)
                                            {
                                                ilpsQuery.searchcontent = list[i];
                                            }
                                            else
                                            {
                                                ilpsQuery.searchcontent = ilpsQuery.searchcontent + "," + list[i];
                                            }
                                        }
                                        else
                                        {
                                            ilpsQuery.searchcontent = ilpsQuery.searchcontent + list[i] + ",";
                                        }
                                    }
                                }

                                #endregion
                                break;
                            default:
                                break;
                        }


                    }


                }
                DateTime time;
                if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
                {
                    ilpsQuery.starttime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
                {
                    ilpsQuery.endtime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                List<IplasQuery> store = new List<IplasQuery>();
                _IiplasMgr = new IplasMgr(mySqlConnectionString);
                store = _IiplasMgr.GetIplasExportList(ilpsQuery);
                dtExcel.Columns.Add("商品編號", typeof(String));
                dtExcel.Columns.Add("商品名稱", typeof(String));
                dtExcel.Columns.Add("料位編號", typeof(String));
                dtExcel.Columns.Add("料位容量", typeof(String));
                dtExcel.Columns.Add("是否買斷", typeof(String));
                dtExcel.Columns.Add("創建人", typeof(String));
                dtExcel.Columns.Add("創建時間", typeof(String));
                for (int i = 0; i < store.Count; i++)
                {
                    DataRow newRow = dtExcel.NewRow();
                    newRow[0] = store[i].item_id.ToString();
                    newRow[1] = store[i].product_name.ToString();
                    newRow[2] = store[i].loc_id.ToString();
                    newRow[3] = store[i].loc_stor_cse_cap.ToString();
                    newRow[4] = store[i].prepaid.ToString() == "0" ? "否" : "是";
                    newRow[5] = store[i].create_users.ToString();
                    newRow[6] = store[i].create_dtim.ToString();
                    dtExcel.Rows.Add(newRow);
                }
                if (dtExcel.Rows.Count > 0)
                {
                    string fileName = "商品指定主料位_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    MemoryStream ms = ExcelHelperXhf.ExportDT(dtExcel, "商品指定主料位_" + 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);
            }
        }
Пример #10
0
        //刪除沒有商品佔據的主料位
        public HttpResponseBase DeleteIplasById()
        {
            string jsonStr = String.Empty;
            _IlocMgr = new IlocMgr(mySqlConnectionString);
            _IiplasMgr = new IplasMgr(mySqlConnectionString);
            Iloc loc = new Iloc();
            IplasQuery plasQuery = new IplasQuery();
            IinvdQuery nvdQery = new IinvdQuery();
            try
            {
                string str = Request.Params["loc_id"].ToString().ToUpper();//獲取類型
                str = str.Substring(0, str.LastIndexOf(","));
                int sum = 0;
                string[] strs = str.Split(',');
                for (int i = 0; i < strs.Length; i++)
                {
                    nvdQery.loc_id = strs[i];
                    sum = sum + _IiplasMgr.GetIinvdItemId(nvdQery);
                }
                if (sum > 0)
                {
                    jsonStr = "{success:true,sum:" + sum + "}";//大於0表示算選包含庫存量
                }
                else
                {
                    int counts = 0;
                    for (int i = 0; i < strs.Length; i++)
                    {
                        plasQuery.loc_id = strs[i];
                        counts = counts + _IiplasMgr.DeleteIplasById(plasQuery);
                    }

                    if (counts > 0)
                    {
                        jsonStr = "{success:true,count:" + counts + "}";
                    }
                    else
                    {
                        jsonStr = "{success:false}";
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Пример #11
0
        //條碼轉換為商品編號
        public string Getprodbyupc(string jsonStr)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                {
                    string prodid = Request.Params["item_id"];
                    if (prodid.Length == 6)
                    {
                        jsonStr = prodid;
                    }
                    else
                    {
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);
                        DataTable dt = _IiplasMgr.Getprodbyupc(prodid);
                        if (dt.Rows.Count > 0)
                        {
                            jsonStr = dt.Rows[0]["item_id"].ToString();
                        }
                        else
                        {
                            jsonStr = string.Empty;
                        }

                    }
                }
            }
            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}";
            }
            return jsonStr;
        }
Пример #12
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;
        }
Пример #13
0
        public HttpResponseBase GetIPlasList()
        {
            string json = string.Empty;

            IplasQuery iplas = new IplasQuery();
            iplas.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
            iplas.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
            //iplas.searchcontent = Request.Params["searchcontent"];

            try
            {
                #region 修改之前


                //if (!string.IsNullOrEmpty(Request.Params["searchcontent"]))
                //{
                //    iplas.searchcontent = Request.Params["searchcontent"].ToString().ToUpper();//輸入的內容
                //    if (iplas.searchcontent.Length > 10)
                //    {
                //        _iinvd = new IinvdMgr(mySqlConnectionString);
                //        DataTable dt = new DataTable();
                //        dt = _iinvd.Getprodubybar(Request.Params["searchcontent"].ToString());
                //        if (dt.Rows.Count > 0)
                //        {
                //            iplas.searchcontent = dt.Rows[0]["item_id"].ToString();
                //        }
                //    }
                //}
                #endregion
                #region 修改之後
                string content = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["search_type"]))
                {
                    iplas.serch_type = int.Parse(Request.Params["search_type"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcontent"]) && Request.Params["searchcontent"].Trim().Length > 0)//有查詢內容就不管時間
                    {

                        switch (iplas.serch_type)
                        {
                            case 1:
                            case 2:
                                iplas.searchcontent = 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)
                                            {
                                                iplas.searchcontent = list[i];
                                            }
                                            else
                                            {
                                                iplas.searchcontent = iplas.searchcontent + "," + list[i];
                                            }
                                        }
                                        else
                                        {
                                            iplas.searchcontent = iplas.searchcontent + list[i] + ",";
                                        }
                                    }
                                }

                                #endregion
                                break;
                            default:
                                break;
                        }


                    }

                }
                DateTime time;
                if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
                {
                    iplas.starttime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
                {
                    iplas.endtime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                #endregion
                //DateTime time;
                //if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time))
                //{
                //    iplas.starttime = time;
                //}
                //if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time))
                //{
                //    iplas.endtime = time;
                //}
                List<IplasQuery> store = new List<IplasQuery>();
                _IiplasMgr = new IplasMgr(mySqlConnectionString);
                //  _IiplasMgr.UpIplas(iplas);
                int totalCount = 0;
                store = _IiplasMgr.GetIplas(iplas, out  totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                foreach (var item in store)
                {
                    item.product_name += GetProductSpec(item.item_id.ToString());
                }
                json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #14
0
        public HttpResponseBase SaveIinvd()
        {
            string json = "{success:false,message:'系統異常'}";
            try
            {
                int temp = 0;
                if (int.TryParse(Request.Params["prod_qty"], out temp))
                {
                    if (temp > 0)
                    {
                        IinvdQuery iinvd = new IinvdQuery();
                        if (!string.IsNullOrEmpty(Request.Params["loc_id"]))
                        {
                            iinvd.plas_loc_id = Request.Params["loc_id"];
                        }
                        if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                        {
                            if (int.TryParse(Request.Params["item_id"], out temp))
                            {
                                iinvd.item_id = uint.Parse(Request.Params["item_id"]);
                            }
                        }

                        #region 判斷是否指定主料位
                        IlocQuery ilocquery = new IlocQuery();
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);
                        IplasQuery iplasquery = new IplasQuery();
                        iplasquery.item_id = iinvd.item_id;
                        IIlocImplMgr ilocMgr = new IlocMgr(mySqlConnectionString);
                        IplasDao iplasdao = new IplasDao(mySqlConnectionString);
                        int total = 0;
                        ilocquery.loc_id = iinvd.plas_loc_id;
                        ilocquery.lcat_id = "0";
                        ilocquery.lsta_id = "";
                        ilocquery.IsPage = false;
                        List<IlocQuery> listiloc = ilocMgr.GetIocList(ilocquery, out total);
                        if (listiloc.Count > 0)
                        {
                            string lcat_id = listiloc.Count == 0 ? "" : listiloc[0].lcat_id;
                            if (lcat_id == "S")
                            {
                                string item_id = iplasdao.Getlocid(ilocquery.loc_id);
                                if (item_id == "")
                                {
                                    Iplas iplas = new Iplas();
                                    if (int.TryParse(Request.Params["item_id"], out temp))
                                    {
                                        iplas.item_id = uint.Parse(Request.Params["item_id"]);
                                        if (_IiplasMgr.IsTrue(iplas) == "false")
                                        {
                                            json = "{success:false,message:'不存在該商品編號'}";
                                            this.Response.Clear();
                                            this.Response.Write(json);
                                            this.Response.End();
                                            return this.Response;
                                        }
                                        if (_IiplasMgr.GetIplasid(iplasquery) > 0)
                                        {
                                            json = "{success:false,message:'此商品主料位非該料位'}";
                                            this.Response.Clear();
                                            this.Response.Write(json);
                                            this.Response.End();
                                            return this.Response;
                                        }
                                        Iloc iloc = new Iloc();
                                        iloc.loc_id = iinvd.plas_loc_id;
                                        if (_IiplasMgr.GetLocCount(iloc) <= 0)
                                        {
                                            json = "{success:false,message:'該料位已鎖定或被指派'}";
                                            this.Response.Clear();
                                            this.Response.Write(json);
                                            this.Response.End();
                                            return this.Response;
                                        }
                                        iplas.loc_id = iloc.loc_id;
                                        iplas.loc_stor_cse_cap = 100;
                                        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);
                                    }
                                }
                            }
                        }
                        #endregion
                        iinvd.create_user = (Session["caller"] as Caller).user_id;
                        iinvd.create_dtim = DateTime.Now;
                        iinvd.change_user = iinvd.create_user;
                        iinvd.change_dtim = iinvd.create_dtim;
                        iinvd.ista_id = "A";
                        if (!string.IsNullOrEmpty(Request.Params["loc_id"]))
                        {
                            iinvd.plas_loc_id = Request.Params["loc_id"];
                        }
                        int change_prod_qty = int.Parse(Request.Params["prod_qty"]);
                        iinvd.prod_qty = change_prod_qty;
                        if (!string.IsNullOrEmpty(Request.Params["st_qty"]))
                        {
                            if (int.TryParse(Request.Params["st_qty"], out temp))
                            {
                                iinvd.st_qty = int.Parse(Request.Params["st_qty"]);
                            }
                        }
                        if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                        {
                            if (int.TryParse(Request.Params["item_id"], out temp))
                            {
                                iinvd.item_id = uint.Parse(Request.Params["item_id"]);
                            }
                        }
                        DateTime date = DateTime.Now;
                        if (DateTime.TryParse(Request.Params["datetimepicker1"], out date))
                        {
                            iinvd.made_date = date;
                        }
                        else
                        {
                            iinvd.made_date = DateTime.Now;
                        }
                        _iinvd = new IinvdMgr(mySqlConnectionString);
                        if (Request.Params["pwy_dte_ctl"] == "Y")
                        {
                            iinvd.pwy_dte_ctl = "Y";
                            IProductExtImplMgr productExt = new ProductExtMgr(mySqlConnectionString);
                            int Cde_dt_incr = productExt.GetCde_dt_incr((int)iinvd.item_id);
                            iinvd.cde_dt = date.AddDays(Cde_dt_incr);
                        }
                        else
                        {
                            iinvd.cde_dt = DateTime.Now;
                        }
                        iinvd.prod_qtys = _iinvd.GetProd_qty(Convert.ToInt32(iinvd.item_id), iinvd.plas_loc_id, "", iinvd.row_id.ToString());
                        IialgQuery iialg = new IialgQuery();
                        iialg.cde_dt = iinvd.cde_dt;
                        int prod_qty = 0;// _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id, "", "");
                        int row = _iinvd.GetIinvdCount(iinvd);
                        if (row > 1)
                        {
                            prod_qty = row - 1;
                            json = "{success:true}";
                        }
                        else
                        {
                            if (_iinvd.Insert(iinvd) == 1)
                            {
                                json = "{success:true}";
                            }
                        }
                        
                        iialg.qty_o = prod_qty;
                        iialg.loc_id = iinvd.plas_loc_id;
                        iialg.item_id = iinvd.item_id;
                        iialg.iarc_id = "循環盤點";
                        iialg.adj_qty = change_prod_qty;
                        iialg.create_dtim = DateTime.Now;
                        iialg.create_user = iinvd.create_user;
                        iialg.type = 2;
                        iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss");
                        iialg.made_dt = iinvd.made_date;
                        iialg.cde_dt = iinvd.cde_dt;
                        _iialgMgr = new IialgMgr(mySqlConnectionString);
                        _iialgMgr.insertiialg(iialg);

                        IstockChangeQuery istock = new IstockChangeQuery();
                        istock.sc_trans_id = iialg.doc_no;
                        istock.item_id = iinvd.item_id;
                        istock.sc_istock_why = 2;
                        istock.sc_trans_type = 2;
                        istock.sc_num_old = iinvd.prod_qtys;
                        istock.sc_num_chg = iialg.adj_qty;
                        istock.sc_num_new = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id,"N","");
                        istock.sc_time = iinvd.create_dtim;
                        istock.sc_user = iinvd.create_user;
                        istock.sc_note = "循環盤點";
                        IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString);
                        istockMgr.insert(istock);
                    }
                    else
                    {
                        json = "{success:false,message:'庫存不能小於1'}";
                    }
                }
                else
                {                  
                    json = "{success:false,message:'庫存請輸入數字'}";
                }
            }
            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;
        }