示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void UpdateGiftsInfo(GiftsInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbGiftsInfo set ");
            strSql.Append("ProductsID=@ProductsID,");
            strSql.Append("StoresID=@StoresID,");
            strSql.Append("gNum=@gNum,");
            strSql.Append("gDateTime=@gDateTime,");
            strSql.Append("gAppendTime=@gAppendTime");
            strSql.Append(" where GiftsID=@GiftsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GiftsID",     SqlDbType.Int,       4),
                new SqlParameter("@ProductsID",  SqlDbType.Int,       4),
                new SqlParameter("@StoresID",    SqlDbType.Int,       4),
                new SqlParameter("@gNum",        SqlDbType.Int,       4),
                new SqlParameter("@gDateTime",   SqlDbType.DateTime),
                new SqlParameter("@gAppendTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.GiftsID;
            parameters[1].Value = model.ProductsID;
            parameters[2].Value = model.StoresID;
            parameters[3].Value = model.gNum;
            parameters[4].Value = model.gDateTime;
            parameters[5].Value = model.gAppendTime;

            DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddGiftsInfo(GiftsInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbGiftsInfo(");
            strSql.Append("ProductsID,StoresID,gNum,gDateTime,gAppendTime)");
            strSql.Append(" values (");
            strSql.Append("@ProductsID,@StoresID,@gNum,@gDateTime,@gAppendTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductsID",  SqlDbType.Int,       4),
                new SqlParameter("@StoresID",    SqlDbType.Int,       4),
                new SqlParameter("@gNum",        SqlDbType.Int,       4),
                new SqlParameter("@gDateTime",   SqlDbType.DateTime),
                new SqlParameter("@gAppendTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.ProductsID;
            parameters[1].Value = model.StoresID;
            parameters[2].Value = model.gNum;
            parameters[3].Value = model.gDateTime;
            parameters[4].Value = model.gAppendTime;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GiftsInfo GetGiftsInfoModel(int GiftsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 GiftsID,ProductsID,StoresID,gNum,gDateTime,gAppendTime,(select sName from tbStoresInfo where StoresID=tbGiftsInfo.StoresID) as StoresName,(select pName from tbProductsInfo where ProductsID=tbGiftsInfo.ProductsID) as ProductsName from tbGiftsInfo ");
            strSql.Append(" where GiftsID=@GiftsID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GiftsID", SqlDbType.Int, 4)
            };
            parameters[0].Value = GiftsID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["GiftsID"].ToString() != "")
                {
                    model.GiftsID = int.Parse(ds.Tables[0].Rows[0]["GiftsID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductsID"].ToString() != "")
                {
                    model.ProductsID = int.Parse(ds.Tables[0].Rows[0]["ProductsID"].ToString());
                }
                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]["gNum"].ToString() != "")
                {
                    model.gNum = int.Parse(ds.Tables[0].Rows[0]["gNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["gDateTime"].ToString() != "")
                {
                    model.gDateTime = DateTime.Parse(ds.Tables[0].Rows[0]["gDateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["gAppendTime"].ToString() != "")
                {
                    model.gAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["gAppendTime"].ToString());
                }
                model.StoresName   = ds.Tables[0].Rows[0]["StoresName"].ToString();
                model.ProductsName = ds.Tables[0].Rows[0]["ProductsName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void UpdateGiftsInfo(GiftsInfo model)
 {
     DatabaseProvider.GetInstance().UpdateGiftsInfo(model);
 }
示例#5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int AddGiftsInfo(GiftsInfo model)
 {
     return(DatabaseProvider.GetInstance().AddGiftsInfo(model));
 }
示例#6
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("7"))
                {
                    Act = HTTPRequest.GetString("Act");
                    if (Act == "Edit")
                    {
                        GiftsID = Utils.StrToInt(HTTPRequest.GetString("gid"), 0);

                        gi = tbGiftsInfo.GetGiftsInfoModel(GiftsID);
                    }
                    if (ispost)
                    {
                        StoresID   = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("StoresID")), 0);
                        ProductsID = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("ProductsID")), 0);
                        gNum       = Utils.StrToInt(Utils.ChkSQL(HTTPRequest.GetString("gNum")), 0);
                        gDateTime  = Utils.IsDateString(Utils.ChkSQL(HTTPRequest.GetString("gDateTime"))) ? DateTime.Parse(Utils.ChkSQL(HTTPRequest.GetString("gDateTime"))) : DateTime.Now;

                        gi.StoresID   = StoresID;
                        gi.ProductsID = ProductsID;
                        gi.gNum       = gNum;
                        gi.gDateTime  = gDateTime;
                        if (StoresID > 0)
                        {
                            if (ProductsID > 0)
                            {
                                if (Act == "Add")
                                {
                                    gi.gAppendTime = gAppendTime;
                                    if (tbGiftsInfo.AddGiftsInfo(gi) > 0)
                                    {
                                        AddMsgLine("创建成功!");
                                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                    }
                                    else
                                    {
                                        AddErrLine("创建失败!");
                                        AddScript("history.back(1);");
                                    }
                                }
                                if (Act == "Edit")
                                {
                                    try
                                    {
                                        tbGiftsInfo.UpdateGiftsInfo(gi);
                                        AddMsgLine("修改成功!");
                                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                    }
                                    catch (Exception ex)
                                    {
                                        AddErrLine("修改失败!<br/>" + ex);
                                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                    }
                                }
                            }
                            else
                            {
                                AddErrLine("产品不能为空!");
                                AddScript("history.back(1);");
                            }
                        }
                        else
                        {
                            AddErrLine("门店不能为空!");
                            AddScript("history.back(1);");
                        }
                    }
                    else
                    {
                        if (Act == "Del")
                        {
                            try
                            {
                                tbGiftsInfo.DeleteGiftsInfo(HTTPRequest.GetString("gid"));
                                AddMsgLine("删除成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            catch (Exception ex)
                            {
                                AddErrLine("删除失败!<br/>" + ex);
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                    }
                }
                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()));
            }
        }