Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.gp_BusinessAmount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into gp_BusinessAmount(");
            strSql.Append("BusinessTime,BusinessAmount,by01,by02)");
            strSql.Append(" values (");
            strSql.Append("@BusinessTime,@BusinessAmount,@by01,@by02)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BusinessTime",   SqlDbType.DateTime),
                new SqlParameter("@BusinessAmount", SqlDbType.Decimal,   9),
                new SqlParameter("@by01",           SqlDbType.Int,       4),
                new SqlParameter("@by02",           SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.BusinessTime;
            parameters[1].Value = model.BusinessAmount;
            parameters[2].Value = model.by01;
            parameters[3].Value = model.by02;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.gp_BusinessAmount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update gp_BusinessAmount set ");
            strSql.Append("BusinessTime=@BusinessTime,");
            strSql.Append("BusinessAmount=@BusinessAmount,");
            strSql.Append("by01=@by01,");
            strSql.Append("by02=@by02");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BusinessTime",   SqlDbType.DateTime),
                new SqlParameter("@BusinessAmount", SqlDbType.Decimal,   9),
                new SqlParameter("@by01",           SqlDbType.Int,       4),
                new SqlParameter("@by02",           SqlDbType.Decimal,   9),
                new SqlParameter("@ID",             SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.BusinessTime;
            parameters[1].Value = model.BusinessAmount;
            parameters[2].Value = model.by01;
            parameters[3].Value = model.by02;
            parameters[4].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            lgk.Model.gp_BusinessAmount model = gp_amountBLL.GetModel(id);
            if (model == null)
            {
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该记录已删除,无法再进行此操作!');window.location.href='trade.aspx'", true);
            }
            else
            {
                if (e.CommandName.Equals("del"))
                {
                    if (gp_amountBLL.Delete(id))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除成功!');", true);
                        bind_num();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除失败!');", true);
                    }
                }
                if (e.CommandName.Equals("edi"))
                {
                    Response.Redirect("TradeEdit.aspx?id=" + id);
                }
            }
        }
Ejemplo n.º 4
0
 private void bind_num()
 {
     if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
     {
         lgk.Model.gp_BusinessAmount model = gp_amountBLL.GetModel(Convert.ToInt32(Request.QueryString["id"]));
         textStar.Value = model.BusinessTime.ToString();
         txtNum.Value   = model.BusinessAmount.ToString();
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.gp_BusinessAmount GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,BusinessTime,BusinessAmount,by01,by02 from gp_BusinessAmount ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            lgk.Model.gp_BusinessAmount model = new lgk.Model.gp_BusinessAmount();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BusinessTime"] != null && ds.Tables[0].Rows[0]["BusinessTime"].ToString() != "")
                {
                    model.BusinessTime = DateTime.Parse(ds.Tables[0].Rows[0]["BusinessTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BusinessAmount"] != null && ds.Tables[0].Rows[0]["BusinessAmount"].ToString() != "")
                {
                    model.BusinessAmount = decimal.Parse(ds.Tables[0].Rows[0]["BusinessAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["by01"] != null && ds.Tables[0].Rows[0]["by01"].ToString() != "")
                {
                    model.by01 = int.Parse(ds.Tables[0].Rows[0]["by01"].ToString());
                }
                if (ds.Tables[0].Rows[0]["by02"] != null && ds.Tables[0].Rows[0]["by02"].ToString() != "")
                {
                    model.by02 = decimal.Parse(ds.Tables[0].Rows[0]["by02"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     if (this.txtStar.Text.Trim().Equals(""))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请选择日期!');", true);
         return;
     }
     else if (Convert.ToDateTime(txtStar.Text).Day < DateTime.Now.Day)
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请选择今天之后的日期!');", true);
         return;
     }
     if (this.txtNum.Value.Trim().Equals(""))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入交易数目!');", true);
         return;
     }
     if (!PageValidate.IsDecimalTwo(this.txtNum.Value.Trim()))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('只能输入整数或者带两位小数的浮点数!');", true);
         return;
     }
     if (gp_amountBLL.Exists(Convert.ToDateTime(this.txtStar.Text)))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('当天已存在记录!');window.location.href='trade.aspx'", true);
     }
     else
     {
         lgk.Model.gp_BusinessAmount model = new lgk.Model.gp_BusinessAmount();
         model.BusinessTime   = Convert.ToDateTime(txtStar.Text);
         model.BusinessAmount = Convert.ToDecimal(txtNum.Value);
         if (gp_amountBLL.Add(model) > 0)
         {
             ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('数据提交成功!');window.location.href='trade.aspx'", true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('提交数据失败!');", true);
             return;
         }
     }
 }
Ejemplo n.º 7
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     if (this.txtNum.Value.Trim().Equals(""))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入交易数目!');", true);
         return;
     }
     if (!PageValidate.IsDecimalTwo(this.txtNum.Value.Trim()))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('只能输入整数或者带两位小数的浮点数!');", true);
         return;
     }
     lgk.Model.gp_BusinessAmount model = gp_amountBLL.GetModel(Convert.ToInt32(Request.QueryString["id"]));;
     model.BusinessAmount = Convert.ToDecimal(txtNum.Value);
     if (gp_amountBLL.Update(model))
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('编辑成功!');window.location.href='trade.aspx'", true);
     }
     else
     {
         ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('编辑失败!');", true);
         return;
     }
 }