Ejemplo n.º 1
0
        /// <summary>
        /// 更新门店库存副本
        /// </summary>
        /// <param name="storehouseStorage"></param>
        /// <returns></returns>
        public int UpdateStorehouseStorageInfo_calculate(StorehouseStoreInfo storehouseStorage)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbStoreStorehouseInfo_calculate set ");
            strSql.Append("pRelityStorage=@inypRelityStorage,");
            strSql.Append("pMoney=@pMoney");
            strSql.Append(" where productStorageID=@chvproductStorageID");

            SqlParameter[] parameters =
            {
                new SqlParameter("@inypRelityStorage",   SqlDbType.Int),
                new SqlParameter("@pMoney",              SqlDbType.Money),
                new SqlParameter("@chvproductStorageID", SqlDbType.Int),
            };

            parameters[0].Value = storehouseStorage.PNum;
            parameters[1].Value = storehouseStorage.PMoney;
            parameters[2].Value = storehouseStorage.ProductStorageID;
            int state = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);

            if (state > 0)
            {
                return(state);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 导入门店库存书库副本
        /// </summary>
        /// <param name="storehouseStorage"></param>
        /// <returns></returns>
        public int AddStorehouseStorageInfo_calculate(StorehouseStoreInfo storehouseStorage)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbStoreStorehouseInfo_calculate(");
            strSql.Append("sCode,sName,StoresID,stCode,stName,ProductsID,pCode,pBarcode,pName,pBrand,pStandard,pRelityStorage,pAppendTime,pUpdateTime,pMoney)");
            strSql.Append(" values (");
            strSql.Append("@chvSCode,@chvSName,@inyStoresID,@chvStCode,@chvStName,@inyProductsID,@chvproCode,@inypBarcode,@chvPName,@chvPBrand,@chvPStandard,@inyStorage,@dtmDateTime,GETDATE(),@meyPMoney)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@chvSCode",      SqlDbType.VarChar,    50),
                new SqlParameter("@chvSName",      SqlDbType.VarChar,   128),
                new SqlParameter("@inyStoresID",   SqlDbType.Int),
                new SqlParameter("@chvStCode",     SqlDbType.VarChar,    50),
                new SqlParameter("@chvStName",     SqlDbType.VarChar,   128),
                new SqlParameter("@inyProductsID", SqlDbType.Int),
                new SqlParameter("@chvproCode",    SqlDbType.VarChar,    50),
                new SqlParameter("@inypBarcode",   SqlDbType.VarChar,    50),
                new SqlParameter("@chvPName",      SqlDbType.VarChar,   128),
                new SqlParameter("@chvPBrand",     SqlDbType.VarChar,   128),
                new SqlParameter("@chvPStandard",  SqlDbType.VarChar,    50),
                new SqlParameter("@inyStorage",    SqlDbType.Int),
                new SqlParameter("@dtmDateTime",   SqlDbType.DateTime),
                new SqlParameter("@meyPMoney",     SqlDbType.Money),
            };

            parameters[0].Value  = storehouseStorage.SCode;
            parameters[1].Value  = storehouseStorage.SName;
            parameters[2].Value  = storehouseStorage.StoresID;
            parameters[3].Value  = storehouseStorage.StCode;
            parameters[4].Value  = storehouseStorage.StName;
            parameters[5].Value  = storehouseStorage.ProductsID;
            parameters[6].Value  = storehouseStorage.ProCode;
            parameters[7].Value  = storehouseStorage.PBarcode;
            parameters[8].Value  = storehouseStorage.PName;
            parameters[9].Value  = storehouseStorage.PBrand;
            parameters[10].Value = storehouseStorage.PStandard;
            parameters[11].Value = storehouseStorage.PNum;
            parameters[12].Value = storehouseStorage.PAppendTime;
            parameters[13].Value = storehouseStorage.PMoney;

            object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(-1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 更新门店库存数据副本
 /// </summary>
 /// <param name="storehouseStorage"></param>
 /// <returns></returns>
 public static int UpdateStorehouseStorageInfo_calculate(StorehouseStoreInfo storehouseStorage)
 {
     return(DatabaseProvider.GetInstance().UpdateStorehouseStorageInfo_calculate(storehouseStorage));
 }
 public static int UpdateStorehouseStorageInfo(StorehouseStoreInfo s)
 {
     return(DatabaseProvider.GetInstance().UpdateStorehouseStorageInfo(s));
 }
 public static int AddStorehouseStorageInfo(StorehouseStoreInfo str)
 {
     return(DatabaseProvider.GetInstance().AddStorehouseStorageInfo(str));
 }
Ejemplo n.º 6
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-4-6-1"))
                {
                    if (Act == "Del")
                    {
                        try
                        {
                            sid = Utils.ChkSQL(HTTPRequest.GetString("sid"));
                            storehouseStorage.DeleteStoragesInfo(sid);
                            AddMsgLine("删除成功!");
                            AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                        }
                        catch (Exception ex)
                        {
                            AddErrLine("创建失败!<br/>" + ex.Message);
                            AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                        }
                    }
                    if (Act == "Edit")
                    {
                        productStorageID = Utils.StrToInt(HTTPRequest.GetString("sid"), 0);

                        si = storehouseStorage.GetStorehouseProductsInfoModel(productStorageID);
                    }
                    if (ispost)
                    {
                        sName          = Utils.ChkSQL(HTTPRequest.GetString("SName"));                                                                                                           //  门店名称
                        stName         = Utils.ChkSQL(HTTPRequest.GetString("stName"));                                                                                                          //仓库名称
                        pName          = Utils.ChkSQL(HTTPRequest.GetString("pName"));                                                                                                           //产品名称
                        pBrand         = Utils.ChkSQL(HTTPRequest.GetString("pBrand"));                                                                                                          //品牌
                        proCode        = Utils.ChkSQL(HTTPRequest.GetString("proCode"));                                                                                                         //产品自编号
                        pStandred      = Utils.ChkSQL(HTTPRequest.GetString("pStandred"));                                                                                                       //产品规格
                        pRelityStorage = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("pNum")), 0);                                                                                         //数量
                        pBarcode       = Utils.ChkSQL(HTTPRequest.GetString("pBarcode"));                                                                                                        //条码
                        pMoney         = Utils.ChkSQL(HTTPRequest.GetString("pMoney"));                                                                                                          //单价
                        sDateTime      = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("sDateTime"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("sDateTime"))) : DateTime.Now; //获取日期

                        StoresID  = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("StoresID")), 0);                                                                                          //直接获取门店编号
                        ProductID = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("ProductID")), 0);                                                                                         //直接获取产品编号


                        pCode = Utils.StrToInt(storehouseStorage.SelectPcodeByName(pName), 0);             //通过产品名称找到产品系统编号
                        int pbrCode = Utils.StrToInt(storehouseStorage.SelectpBarcodeByName(pBarcode), 0); //通过产品条码获得产品编号

                        si.SName       = sName;
                        si.StCode      = "默认值";
                        si.StName      = "默认值";
                        si.PAppendTime = sDateTime;
                        si.StoresID    = StoresID;
                        si.ProductsID  = ProductID;
                        si.ProCode     = proCode;
                        si.PBarcode    = pBarcode;
                        si.PName       = pName;
                        si.PBrand      = pBrand;
                        si.PStandard   = pStandred;
                        si.PNum        = pRelityStorage;
                        si.PMoney      = pMoney;


                        if (Act == "Add")
                        {
                            if (StoresID > 0)
                            {
                                if (sDateTime > DateTime.Now)
                                {
                                    AddMsgLine("创建时间不能大于当前时间,请重新选择!");
                                }
                                else
                                {
                                    if (ProductID > 0)
                                    {
                                        bool state = storehouseStorage.GetDateTimeDataStorehouseInfoList(sDateTime, StoresID, stCode, pCode);
                                        if (state)
                                        {
                                            AddErrLine("该产品[" + pName + "]数据库已经存在!");
                                        }
                                        else
                                        {
                                            if (storehouseStorage.AddStorehouseStorageInfo(si) > 0)
                                            {
                                                storehouseStorage.AddStorehouseStorageInfo_calculate(si);
                                                AddMsgLine("创建成功!");
                                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                            }
                                            else
                                            {
                                                AddErrLine("创建失败!");
                                                AddScript("window.setTimeout('history.back(1);',1000);");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        AddMsgLine("该产品[" + pName + "]编号不存在!");
                                    }
                                }
                            }
                            else
                            {
                                AddMsgLine("该门店[" + sName + "]编号不存在!请确认后再次输入或先添加该门店!");
                            }
                        }
                        if (Act == "Edit")
                        {
                            productStorageID    = Utils.StrToInt(HTTPRequest.GetString("sid"), 0);
                            si.ProductStorageID = productStorageID;
                            try
                            {
                                int state = storehouseStorage.UpdateStorehouseStorageInfo(si);
                                if (state > 0)
                                {
                                    AddMsgLine("修改成功!");
                                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                }
                                else
                                {
                                    AddErrLine("修改失败!<br/>");
                                }
                            }
                            catch (Exception ex)
                            {
                                AddErrLine("错误信息!<br/>" + ex.Message);
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                    AddScript("window.parent.HidBox();");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
Ejemplo n.º 7
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (ispost)
            {
                if (this.userid > 0)
                {
                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-4-6-1"))
                    {
                        //获取前台的门店名称与仓库名称
                        sName  = HTTPRequest.GetString("SName").Trim();
                        stName = HTTPRequest.GetString("stName").Trim();
                        //获取前台选择的时间
                        DateTime sDateTime = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("dtime"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("dtime"))) : DateTime.Now;
                        //根据门店名称取出门店编号
                        sNum = storehouseStorage.GetScodeBySname(sName);
                        //判断输入的门店名称的名称编号是否存在
                        StoresID = Utils.StrToInt(HTTPRequest.GetString("StoresID"), 0);
                        if (sNum.Rows.Count > 0)
                        {
                            //判断选择时间是否大于当前时间
                            if (sDateTime > DateTime.Now)
                            {
                                AddErrLine("日期选择错误,不能大于当前日期,请重新选择!");
                            }
                            else
                            {
                                //获取上传文件路径
                                string    PathStr          = Utils.GetMapPath(config.DataPath.ToString());
                                string    fileExtension    = "";
                                string    fileName         = "";
                                string    thispath         = DateTime.Now.Year + "-" + DateTime.Now.Month;
                                ArrayList filearr          = new ArrayList();
                                int       importdata_count = 0;
                                if (!Directory.Exists(PathStr + thispath))
                                {
                                    Directory.CreateDirectory(PathStr + thispath);
                                }

                                //上传文件
                                HttpFileCollection files = HttpContext.Current.Request.Files;
                                try
                                {
                                    if (files.Count > 0)
                                    {
                                        for (int i = 0; i < files.Count; i++)
                                        {
                                            HttpPostedFile postedFile = files[i];
                                            fileName = System.IO.Path.GetFileName(postedFile.FileName);
                                            if (Utils.ChkSQL(fileName) != "")
                                            {
                                                fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
                                                if (fileExtension == ".xls")
                                                {
                                                    postedFile.SaveAs(PathStr + thispath + "/" + fileName);
                                                    filearr.Add(PathStr + thispath + "/" + fileName);
                                                }
                                                else
                                                {
                                                    AddErrLine("<b>文件格式错误,请将 Xls 文件用 Excel 另存后再导入!</b>:<br>");
                                                }
                                            }
                                        }
                                    }
                                    if (filearr.Count > 0)
                                    {
                                        StorehouseStoreInfo pi = new StorehouseStoreInfo();
                                        for (int j = 0; j < filearr.Count; j++)
                                        {
                                            DataSet   ds = Excels.ExcelToDataTable(filearr[j].ToString());
                                            DataTable dt = new DataTable();
                                            try
                                            {
                                                dt = ds.Tables[0];
                                                foreach (DataRow dr in dt.Rows)
                                                {
                                                    string pName = dr[1].ToString().Trim(); //产品名称
                                                    string pNum  = dr[3].ToString().Trim(); //获得产品数量
                                                    pMoney = dr[4].ToString().Trim();       //获得产品单价

                                                    if (pName != "" && Utils.IsNumeric(pNum) && Utils.IsNumeric(pMoney))
                                                    {
                                                        int    proCode  = Utils.StrToInt(storehouseStorage.SelectPcodeByName(pName), 0); //通过产品名称获得产品编号
                                                        string pBarcode = Utils.ChkSQL(dr[0].ToString().Trim());                         //产品条码
                                                        string sCode    = storehouseStorage.GetScode(sName);                             //门店编号
                                                        string stCode   = "默认值";                                                         //仓库编号 暂取默认值



                                                        pi.SName       = sName;
                                                        pi.StoresID    = StoresID;//匹配添加未成功记录状态=0  门店系统编号唯一
                                                        pi.StCode      = stCode;
                                                        pi.StName      = stName;
                                                        pi.ProductsID  = proCode;
                                                        pi.ProCode     = dr[2].ToString().Trim();
                                                        pi.PName       = pName;
                                                        pi.PBrand      = dr[5].ToString().Trim();
                                                        pi.PStandard   = dr[6].ToString().Trim();
                                                        pi.PNum        = Utils.StrToInt(pNum, 0);
                                                        pi.PMoney      = pMoney;
                                                        pi.PBarcode    = pBarcode;
                                                        pi.PAppendTime = sDateTime;
                                                        if (pBarcode == "")
                                                        {
                                                            pBarcode    = "null";
                                                            pi.PBarcode = pBarcode;
                                                            if (proCode > 0)
                                                            {
                                                                bool state = storehouseStorage.GetDateTimeDataStorehouse(StoresID, "默认值", proCode, pName, pBarcode, pNum, sDateTime);
                                                                if (state)
                                                                {
                                                                    AddErrLine("数据重复:产品条码[" + pBarcode + "];产品名称[" + pName + "]");
                                                                }
                                                                else
                                                                {
                                                                    if (storehouseStorage.AddStorehouseStorageInfo(pi) > 0)
                                                                    {
                                                                        storehouseStorage.AddStorehouseStorageInfo_calculate(pi);
                                                                        importdata_count++;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AddMsgLine("该产品[" + pName + "];产品条码[" + pBarcode + "]库中不存在!");
                                                            }
                                                        }
                                                        else
                                                        {
                                                            int pbrCode = Utils.StrToInt(storehouseStorage.SelectpBarcodeByName(pBarcode).ToString(), 0);//通过产品条码获得产品编号
                                                            if (pbrCode > 0 || proCode > 0)
                                                            {
                                                                bool state = storehouseStorage.GetDateTimeDataStorehouse(StoresID, "默认值", proCode, pName, pBarcode, pNum, sDateTime);
                                                                if (state)
                                                                {
                                                                    AddErrLine("数据重复:产品条码[" + pBarcode + "];产品名称[" + pName + "]");
                                                                }
                                                                else
                                                                {
                                                                    if (storehouseStorage.AddStorehouseStorageInfo(pi) > 0)
                                                                    {
                                                                        storehouseStorage.AddStorehouseStorageInfo_calculate(pi);
                                                                        importdata_count++;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AddMsgLine("该产品[" + pName + "];产品条码[" + pBarcode + "]库中不存在!");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            finally
                                            {
                                                ds.Clear();
                                                ds.Dispose();
                                            }
                                        }

                                        if (importdata_count > 0)
                                        {
                                            AddMsgLine("数据导入成功!共导入数据[" + importdata_count.ToString() + "]条.");
                                            //AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                        }
                                        else
                                        {
                                            AddErrLine("系统忙!导入失败!");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    AddErrLine("错误信息" + ex.Message);
                                }
                            }
                        }
                        else
                        {
                            AddMsgLine("该门店[" + sName + "]编号不存在!请确认后再次输入或先添加该门店!");
                        }
                    }
                    else
                    {
                        AddErrLine("权限不足!");
                        AddScript("window.parent.HidBox();");
                    }
                }
                else
                {
                    AddErrLine("请先登录!");
                    SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                    SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 实体副本
        /// </summary>
        /// <param name="ProductID"></param>
        /// <returns></returns>
        public StorehouseStoreInfo GetStorehouseProductsInfoModel_calculate(int ProductID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 StoresID,sCode,sName,StCode,stName,ProductsID,pCode,pBarcode,pName,pBrand,pStandard,pRelityStorage,pAppendTime,pMoney from tbStoreStorehouseInfo_calculate  ");
            strSql.Append(" where productStorageID=@productStorageID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productStorageID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProductID;

            StorehouseStoreInfo model = new StorehouseStoreInfo();
            DataSet             ds    = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["StoresID"].ToString() != "")
                {
                    model.StoresID = int.Parse(ds.Tables[0].Rows[0]["StoresID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sCode"].ToString() != "")
                {
                    model.SCode = ds.Tables[0].Rows[0]["sCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sName"].ToString() != "")
                {
                    model.SName = ds.Tables[0].Rows[0]["sName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StCode"].ToString() != "")
                {
                    model.StCode = ds.Tables[0].Rows[0]["StCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["stName"].ToString() != "")
                {
                    model.StName = ds.Tables[0].Rows[0]["stName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductsID"].ToString() != "")
                {
                    model.ProductsID = Int32.Parse(ds.Tables[0].Rows[0]["ProductsID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pCode"].ToString() != "")
                {
                    model.ProCode = ds.Tables[0].Rows[0]["pCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pBarcode"].ToString() != "")
                {
                    model.PBarcode = ds.Tables[0].Rows[0]["pBarcode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pName"].ToString() != "")
                {
                    model.PName = ds.Tables[0].Rows[0]["pName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pBrand"].ToString() != "")
                {
                    model.PBrand = ds.Tables[0].Rows[0]["pBrand"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pStandard"].ToString() != "")
                {
                    model.PStandard = ds.Tables[0].Rows[0]["pStandard"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pRelityStorage"].ToString() != "")
                {
                    model.PNum = Int32.Parse(ds.Tables[0].Rows[0]["pRelityStorage"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pAppendTime"].ToString() != "")
                {
                    model.PAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["pAppendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pMoney"].ToString() != "")
                {
                    model.PMoney = ds.Tables[0].Rows[0]["pMoney"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }