예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Prize DataRowToModel(DataRow row)
        {
            Model.Prize model = new Model.Prize();
            if (row != null)
            {
                if (row["AutoID"] != null)
                {
                    model.AutoID = long.Parse(row["AutoID"].ToString());
                }
                if (row["PrizeName"] != null && row["PrizeName"].ToString() != "")
                {
                    model.PrizeName = row["PrizeName"].ToString();
                }
                if (row["PrizeUnit"] != null && row["PrizeUnit"].ToString() != "")
                {
                    model.PrizeUnit = row["PrizeUnit"].ToString();
                }
                if (row["Points"] != null)
                {
                    model.Points =int.Parse( row["Points"].ToString());
                }
                if (row["Registrant"] != null && row["Registrant"].ToString() != "")
                {
                    model.Registrant = row["Registrant"].ToString();
                }
                if (row["Stock"] != null)
                {
                    model.Stock = long.Parse( row["Stock"].ToString());
                }
                if (row["Remarks"] != null && row["Remarks"].ToString() != "")
                {
                    model.Remarks = row["Remarks"].ToString();
                }
                if (row["RegTime"] != null && row["RegTime"].ToString() != "")
                {
                    model.RegTime = DateTime.Parse(row["RegTime"].ToString());
                }
                if (row["Picture"] != null && row["Picture"].ToString() != "")
                {
                    model.Picture = row["Picture"].ToString();
                }

            }
            return model;
        }
예제 #2
0
        protected void RbtnSubmit_Click(object sender, EventArgs e)
        {
            Model.Log logModel = new Model.Log();
            logModel.OperationItem = "定义礼品";
            logModel.OperationTime = DateTime.Now;
            logModel.Operator = _user.UserInfo.UserID;
            logModel.OperationDetail = "";
            logModel.Memo = "";
            long addId = 0;
            if (GName.Text.Trim().Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,礼品名称不能为空!');", true);
                return;
            }
            if (GUnit.Text.Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,单位不能为空!');", true);
                return;
            }
            if (GStockn.Text.Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,库存不能为空!');", true);
                return;
            }
            else if (int.Parse(GStockn.Text) <= 0)
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,库存值必须大于零!');", true);
                return;
            }
            if (GPointsn.Text.Equals(""))
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,兑换分值不能为空!');", true);
                return;
            }
            else if (int.Parse(GPointsn.Text) <= 0)
            {
                RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,兑换分值必须大于零!');", true);
                return;
            }

            try
            {
                Model.Prize prModel = new Model.Prize();
                prModel.Points = int.Parse(GPointsn.Text);
                prModel.PrizeName = GName.Text;
                prModel.PrizeUnit = GUnit.Text;
                prModel.Registrant = _user.UserInfo.UserID;
                prModel.RegTime = DateTime.Now;
                prModel.Remarks = GMemo.Text;
                prModel.Stock = long.Parse(GStockn.Text);
                addId =pr.Add(prModel);
                logModel.OperationDetail = prModel.PrizeName + "-" + prModel.PrizeUnit + "-" + prModel.Stock;
            }
            catch (Exception ex)
            {
                logModel.Memo = ex.Message;
            }
            finally
            {
                log.Add(logModel);
                if (addId > 0)
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('恭喜,礼品定义成功!');", true);
                }
                else
                {
                    RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "c1", "OpenAlert('抱歉,礼品定义失败!');", true);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Prize GetModel(long AutoID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select AutoID,PrizeName,PrizeUnit,Points,Registrant,Stock,Remarks,RegTime,Picture from Prize");
            strSql.Append(" where AutoID=@AutoID limit 1");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@AutoID", MySqlDbType.Int64)
            };
            parameters[0].Value = AutoID;

            Model.Prize model = new Model.Prize();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     _user = SessionUser.GetSession();
     if (!IsPostBack)
     {
         List<Model.Prize> prList = pr.GetModelList(-1, "", -1, 7, true);
         Model.Prize prM = new Model.Prize();
         prM.PrizeName = "不限";
         prM.AutoID = -1;
         prList.Insert(0, prM);
         RCB_Prize.DataTextField = "PrizeName";
         RCB_Prize.DataValueField = "AutoID";
         RCB_Prize.DataSource = prList;
         RCB_Prize.DataBind();
         RGrid_List.Visible = false;
     }
 }