示例#1
0
 public int Updspecstatus(ProductStockQuery m)
 {
     try
     {
         return _specDao.Updspecstatus(m);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductSpecMgr-->Updspecstatus-->" + ex.Message, ex);
     }
 }
示例#2
0
        /// <summary>
        /// 上傳文件,匯入到datatable里
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase UploadExcel()
        {
            string newName = string.Empty;
            string json = string.Empty;
            productStockStores = new List<ProductStockQuery>();
            try
            {
                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)
                    {
                        ProductStockQuery ps;
                        _pStockMgr = new ProductStockImportMgr(connectionString);
                        foreach (DataRow dr in dt.Rows)
                        {
                            ps = new ProductStockQuery();
                            ps.item_id = dr["細項編號"].ToString();
                            ps.product_id = dr["商品編號"].ToString();
                            ps.item_stock = dr["庫存"].ToString();
                            ps.item_alarm = dr["警告值"].ToString();
                            ps.product_name = dr["商品名稱"].ToString();
                            ps.spec_name1 = dr["規格1"].ToString();
                            ps.spec_name2 = dr["規格2"].ToString();
                            ps.product_mode = dr["出貨方式"].ToString();
                            ps.prepaid = dr["已買斷商品"].ToString();
                            ps.spec_status = dr["規格1顯示狀態"].ToString();
                            ps.spec_status2 = dr["規格2顯示狀態"].ToString();
                            //if (ps.spec_status == "顯示")
                            //{
                            //    ps.spec_status = "1";
                            //}
                            //else if (ps.spec_status == "隱藏")
                            //{
                            //    ps.spec_status = "0";
                            //}
                            //else {
                            //    ps.spec_status = string.Empty;
                            //}
                            //if (ps.spec_status2 == "顯示")
                            //{
                            //    ps.spec_status2 = "1";
                            //}
                            //else if (ps.spec_status2 == "隱藏")
                            //{
                            //    ps.spec_status2 = "0";
                            //}
                            //else
                            //{
                            //    ps.spec_status2 = string.Empty;
                            //}
                            ps.remark = dr["備註"].ToString();

                            if (dr[11].ToString() == "寄倉" || dr[12].ToString() == "是")
                            {
                                ps.type = 1;
                            }
                            productStockStores.Add(ps);
                        }
                    }
                    json = "{success:true,data:" + JsonConvert.SerializeObject(productStockStores, Formatting.Indented) + "}";
                }
            }
            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;
        }
示例#3
0
        public int Updspecstatus(ProductStockQuery m)
        {
            StringBuilder stb = new StringBuilder();
            StringBuilder sql = new StringBuilder();
            DataTable dt = new DataTable();
            try
            {
                sql.AppendFormat("SELECT spec_id_1,spec_id_2 from product_item where item_id ='{0}'", m.item_id);
                dt = _dbAccess.getDataTable(sql.ToString());

                if (!string.IsNullOrEmpty(m.spec_status))
                {
                    if (dt.Rows[0]["spec_id_1"].ToString() != "0" && dt.Rows[0]["spec_id_1"] != null)
                    {
                        stb.AppendFormat("set sql_safe_updates = 0;update product_spec set spec_status='{1}' where spec_id='{0}';set sql_safe_updates = 1; ", dt.Rows[0]["spec_id_1"], m.spec_status);
                    }
                }
                if (!string.IsNullOrEmpty(m.spec_status2))
                {
                    if (dt.Rows[0]["spec_id_2"].ToString() != "0" && dt.Rows[0]["spec_id_2"] != null)
                    {
                        stb.AppendFormat("set sql_safe_updates = 0;update product_spec set spec_status='{1}' where spec_id='{0}';set sql_safe_updates = 1; ", dt.Rows[0]["spec_id_2"], m.spec_status2);
                    }
                }
                if (stb.ToString().Length > 0)
                {
                    return _dbAccess.execCommand(stb.ToString());
                }
                else
                {
                    return 0;
                }

            }
            catch (Exception ex)
            {
                throw new Exception("ProductSpecDao.Updspecstatus-->" + ex.Message + stb + ";" + sql, ex);
            }
        }