Beispiel #1
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            lgk.Model.gp_StockPrice model = gp_priceBLL.GetModel(id);
            if (model == null)
            {
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('已删除,无法再进行此操作!');window.location.href='jiaoyijiage.aspx'", true);
            }
            else
            {
                if (e.CommandName == "del")
                {
                    if (gp_priceBLL.Delete(id))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除成功!');", true);
                        bind();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('删除失败!');", true);
                    }
                }
                if (e.CommandName == "edit")
                {
                    Response.Redirect("StockPriceEdit.aspx?ID=" + id);
                }
            }
        }
Beispiel #2
0
 private void bind_update()
 {
     if (Request.QueryString["ID"] != "" && Request.QueryString["ID"] != null)
     {
         lgk.Model.gp_StockPrice model = gp_priceBLL.GetModel(Convert.ToInt32(Request.QueryString["ID"]));
         text_startDate.Value = model.BusinessTime.ToString();
         txt_back.Text        = model.UpPrice.ToString();
         txt_open.Text        = model.OpenMoney.ToString();
         if (model.PriceType == 2)
         {
             RadioButton1.Checked  = true;
             text_up.Value         = model.Price.ToString();
             text_upday.Value      = model.Up_DropDayNumber.ToString();
             text_down.Disabled    = false;
             text_downday.Disabled = false;
         }
         else if (model.PriceType == 3)
         {
             RadioButton2.Checked = true;
             text_down.Value      = model.Price.ToString();
             text_downday.Value   = model.Up_DropDayNumber.ToString();
             text_up.Disabled     = false;
             text_upday.Disabled  = false;
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.gp_StockPrice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into gp_StockPrice(");
            strSql.Append("PriceType,BusinessTime,UpPrice,OpenMoney,Price,Up_DropDayNumber,LastOpenMoney,LastUp_DropDayNumber,AddTime,Price01,Price02,Price03,Price04,Price05,Price06,Price07,Price08)");
            strSql.Append(" values (");
            strSql.Append("@PriceType,@BusinessTime,@UpPrice,@OpenMoney,@Price,@Up_DropDayNumber,@LastOpenMoney,@LastUp_DropDayNumber,@AddTime,@Price01,@Price02,@Price03,@Price04,@Price05,@Price06,@Price07,@Price08)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PriceType",            SqlDbType.Int,       4),
                new SqlParameter("@BusinessTime",         SqlDbType.DateTime),
                new SqlParameter("@UpPrice",              SqlDbType.Decimal,   9),
                new SqlParameter("@OpenMoney",            SqlDbType.Decimal,   9),
                new SqlParameter("@Price",                SqlDbType.Decimal,   9),
                new SqlParameter("@Up_DropDayNumber",     SqlDbType.Int,       4),
                new SqlParameter("@LastOpenMoney",        SqlDbType.Decimal,   9),
                new SqlParameter("@LastUp_DropDayNumber", SqlDbType.DateTime),
                new SqlParameter("@AddTime",              SqlDbType.DateTime),
                new SqlParameter("@Price01",              SqlDbType.Int,       4),
                new SqlParameter("@Price02",              SqlDbType.Int,       4),
                new SqlParameter("@Price03",              SqlDbType.Int,       4),
                new SqlParameter("@Price04",              SqlDbType.DateTime),
                new SqlParameter("@Price05",              SqlDbType.DateTime),
                new SqlParameter("@Price06",              SqlDbType.Decimal,   9),
                new SqlParameter("@Price07",              SqlDbType.Decimal,   9),
                new SqlParameter("@Price08",              SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = model.PriceType;
            parameters[1].Value  = model.BusinessTime;
            parameters[2].Value  = model.UpPrice;
            parameters[3].Value  = model.OpenMoney;
            parameters[4].Value  = model.Price;
            parameters[5].Value  = model.Up_DropDayNumber;
            parameters[6].Value  = model.LastOpenMoney;
            parameters[7].Value  = model.LastUp_DropDayNumber;
            parameters[8].Value  = model.AddTime;
            parameters[9].Value  = model.Price01;
            parameters[10].Value = model.Price02;
            parameters[11].Value = model.Price03;
            parameters[12].Value = model.Price04;
            parameters[13].Value = model.Price05;
            parameters[14].Value = model.Price06;
            parameters[15].Value = model.Price07;
            parameters[16].Value = model.Price08;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Beispiel #4
0
        public bool CheckAmount(decimal amount)
        {
            decimal hig = getGPAmount("kp_max_rate");
            decimal dow = getGPAmount("kp_min_rate");

            lgk.Model.gp_StockPrice vary = gp_priceBLL.GetModel(" Convert(nvarchar(10),BusinessTime,120)=Convert(nvarchar(10),getdate(),120)");
            decimal varyAmount           = Convert.ToDecimal(vary.OpenMoney);
            decimal higAmount            = varyAmount * hig / 100 + varyAmount;
            decimal dowAmount            = varyAmount - varyAmount * dow / 100;

            if (amount > higAmount)
            {
                return(false);
            }
            else if (amount < dowAmount)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.gp_StockPrice GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,PriceType,BusinessTime,UpPrice,OpenMoney,Price,Up_DropDayNumber,LastOpenMoney,LastUp_DropDayNumber,AddTime,Price01,Price02,Price03,Price04,Price05,Price06,Price07,Price08 from gp_StockPrice ");
            strSql.Append(" where " + strWhere);


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

            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]["PriceType"] != null && ds.Tables[0].Rows[0]["PriceType"].ToString() != "")
                {
                    model.PriceType = int.Parse(ds.Tables[0].Rows[0]["PriceType"].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]["UpPrice"] != null && ds.Tables[0].Rows[0]["UpPrice"].ToString() != "")
                {
                    model.UpPrice = decimal.Parse(ds.Tables[0].Rows[0]["UpPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OpenMoney"] != null && ds.Tables[0].Rows[0]["OpenMoney"].ToString() != "")
                {
                    model.OpenMoney = decimal.Parse(ds.Tables[0].Rows[0]["OpenMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Up_DropDayNumber"] != null && ds.Tables[0].Rows[0]["Up_DropDayNumber"].ToString() != "")
                {
                    model.Up_DropDayNumber = int.Parse(ds.Tables[0].Rows[0]["Up_DropDayNumber"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastOpenMoney"] != null && ds.Tables[0].Rows[0]["LastOpenMoney"].ToString() != "")
                {
                    model.LastOpenMoney = decimal.Parse(ds.Tables[0].Rows[0]["LastOpenMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastUp_DropDayNumber"] != null && ds.Tables[0].Rows[0]["LastUp_DropDayNumber"].ToString() != "")
                {
                    model.LastUp_DropDayNumber = DateTime.Parse(ds.Tables[0].Rows[0]["LastUp_DropDayNumber"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"] != null && ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price01"] != null && ds.Tables[0].Rows[0]["Price01"].ToString() != "")
                {
                    model.Price01 = int.Parse(ds.Tables[0].Rows[0]["Price01"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price02"] != null && ds.Tables[0].Rows[0]["Price02"].ToString() != "")
                {
                    model.Price02 = int.Parse(ds.Tables[0].Rows[0]["Price02"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price03"] != null && ds.Tables[0].Rows[0]["Price03"].ToString() != "")
                {
                    model.Price03 = int.Parse(ds.Tables[0].Rows[0]["Price03"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price04"] != null && ds.Tables[0].Rows[0]["Price04"].ToString() != "")
                {
                    model.Price04 = DateTime.Parse(ds.Tables[0].Rows[0]["Price04"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price05"] != null && ds.Tables[0].Rows[0]["Price05"].ToString() != "")
                {
                    model.Price05 = DateTime.Parse(ds.Tables[0].Rows[0]["Price05"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price06"] != null && ds.Tables[0].Rows[0]["Price06"].ToString() != "")
                {
                    model.Price06 = decimal.Parse(ds.Tables[0].Rows[0]["Price06"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price07"] != null && ds.Tables[0].Rows[0]["Price07"].ToString() != "")
                {
                    model.Price07 = decimal.Parse(ds.Tables[0].Rows[0]["Price07"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price08"] != null && ds.Tables[0].Rows[0]["Price08"].ToString() != "")
                {
                    model.Price08 = decimal.Parse(ds.Tables[0].Rows[0]["Price08"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.gp_StockPrice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update gp_StockPrice set ");
            strSql.Append("PriceType=@PriceType,");
            strSql.Append("BusinessTime=@BusinessTime,");
            strSql.Append("UpPrice=@UpPrice,");
            strSql.Append("OpenMoney=@OpenMoney,");
            strSql.Append("Price=@Price,");
            strSql.Append("Up_DropDayNumber=@Up_DropDayNumber,");
            strSql.Append("LastOpenMoney=@LastOpenMoney,");
            strSql.Append("LastUp_DropDayNumber=@LastUp_DropDayNumber,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Price01=@Price01,");
            strSql.Append("Price02=@Price02,");
            strSql.Append("Price03=@Price03,");
            strSql.Append("Price04=@Price04,");
            strSql.Append("Price05=@Price05,");
            strSql.Append("Price06=@Price06,");
            strSql.Append("Price07=@Price07,");
            strSql.Append("Price08=@Price08");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PriceType",            SqlDbType.Int,       4),
                new SqlParameter("@BusinessTime",         SqlDbType.DateTime),
                new SqlParameter("@UpPrice",              SqlDbType.Decimal,   9),
                new SqlParameter("@OpenMoney",            SqlDbType.Decimal,   9),
                new SqlParameter("@Price",                SqlDbType.Decimal,   9),
                new SqlParameter("@Up_DropDayNumber",     SqlDbType.Int,       4),
                new SqlParameter("@LastOpenMoney",        SqlDbType.Decimal,   9),
                new SqlParameter("@LastUp_DropDayNumber", SqlDbType.DateTime),
                new SqlParameter("@AddTime",              SqlDbType.DateTime),
                new SqlParameter("@Price01",              SqlDbType.Int,       4),
                new SqlParameter("@Price02",              SqlDbType.Int,       4),
                new SqlParameter("@Price03",              SqlDbType.Int,       4),
                new SqlParameter("@Price04",              SqlDbType.DateTime),
                new SqlParameter("@Price05",              SqlDbType.DateTime),
                new SqlParameter("@Price06",              SqlDbType.Decimal,   9),
                new SqlParameter("@Price07",              SqlDbType.Decimal,   9),
                new SqlParameter("@Price08",              SqlDbType.Decimal,   9),
                new SqlParameter("@ID",                   SqlDbType.BigInt, 8)
            };
            parameters[0].Value  = model.PriceType;
            parameters[1].Value  = model.BusinessTime;
            parameters[2].Value  = model.UpPrice;
            parameters[3].Value  = model.OpenMoney;
            parameters[4].Value  = model.Price;
            parameters[5].Value  = model.Up_DropDayNumber;
            parameters[6].Value  = model.LastOpenMoney;
            parameters[7].Value  = model.LastUp_DropDayNumber;
            parameters[8].Value  = model.AddTime;
            parameters[9].Value  = model.Price01;
            parameters[10].Value = model.Price02;
            parameters[11].Value = model.Price03;
            parameters[12].Value = model.Price04;
            parameters[13].Value = model.Price05;
            parameters[14].Value = model.Price06;
            parameters[15].Value = model.Price07;
            parameters[16].Value = model.Price08;
            parameters[17].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
        protected void btn_ok_Click(object sender, EventArgs e)
        {
            if (CheckDatabase())
            {
                bool     flag                 = false;
                int      PriceType            = 1;
                DateTime BusinessTime         = Convert.ToDateTime(this.txt_startDate.Text);
                decimal  UpPrice              = Convert.ToDecimal(txt_back.Text.Trim());
                decimal  OpenMoney            = Convert.ToDecimal(this.txt_open.Text.Trim());
                decimal  Price                = 0;
                int      Up_DropDayNumber     = 1;
                decimal  lastOpenMoney        = Convert.ToDecimal(this.txt_open.Text.Trim());
                DateTime LastUp_DropDayNumber = DateTime.Now;

                if (RadioButton1.Checked == true && this.text_up.Value.Trim() != "" && this.text_upday.Value.Trim() != "") //涨价
                {
                    PriceType        = 2;
                    Price            = Convert.ToDecimal(this.text_up.Value);
                    Up_DropDayNumber = Convert.ToInt32(this.text_upday.Value) + 1;

                    //lastOpenMoney = Convert.ToDecimal(this.txt_open.Text) + Convert.ToDecimal(this.text_up.Value) * Convert.ToInt32(this.text_upday.Value);
                    LastUp_DropDayNumber = Convert.ToDateTime(this.txt_startDate.Text).AddDays(Convert.ToDouble(this.text_upday.Value));
                }
                if (RadioButton2.Checked == true && this.text_down.Value.Trim() != "" && this.text_downday.Value.Trim() != "") //跌价
                {
                    PriceType        = 3;
                    Price            = Convert.ToDecimal(this.text_down.Value);
                    Up_DropDayNumber = Convert.ToInt32(this.text_downday.Value) + 1;
                    //lastOpenMoney = Convert.ToDecimal(this.txt_open.Text) - Convert.ToDecimal(this.text_down.Value) * Convert.ToInt32(this.text_downday.Value);
                    LastUp_DropDayNumber = Convert.ToDateTime(this.txt_startDate.Text).AddDays(Convert.ToDouble(this.text_downday.Value));
                }

                //if (Convert.ToDecimal(this.txt_open.Text.Trim()) >= 1)
                //{
                //    MessageBox.Show(this, "开盘价格已经大于或者等于1");
                //}
                for (int i = 0; i < Up_DropDayNumber; i++)
                {
                    lgk.Model.gp_StockPrice price = new lgk.Model.gp_StockPrice();
                    if (i == 0)
                    {
                        price.PriceType            = PriceType;
                        price.BusinessTime         = BusinessTime;
                        price.UpPrice              = UpPrice;
                        price.OpenMoney            = OpenMoney;
                        price.Price                = Price;
                        price.Up_DropDayNumber     = Up_DropDayNumber - 1;
                        price.LastOpenMoney        = lastOpenMoney;
                        price.LastUp_DropDayNumber = LastUp_DropDayNumber;
                        price.AddTime              = DateTime.Now;
                    }
                    else if (i == 1)
                    {
                        if (PriceType == 2)
                        {
                            price.PriceType            = PriceType;
                            price.BusinessTime         = BusinessTime.AddDays(i);
                            price.UpPrice              = OpenMoney;
                            price.OpenMoney            = OpenMoney + Price * (i);
                            price.Price                = Price;
                            price.Up_DropDayNumber     = Up_DropDayNumber - 1 - i;
                            price.LastOpenMoney        = lastOpenMoney + Price * (i);
                            price.LastUp_DropDayNumber = LastUp_DropDayNumber;
                            price.AddTime              = DateTime.Now;
                        }
                        else
                        {
                            price.PriceType            = PriceType;
                            price.BusinessTime         = BusinessTime.AddDays(i);
                            price.UpPrice              = OpenMoney;
                            price.OpenMoney            = OpenMoney - Price * (i);
                            price.Price                = Price;
                            price.Up_DropDayNumber     = Up_DropDayNumber - 1 - i;
                            price.LastOpenMoney        = lastOpenMoney - Price * (i);
                            price.LastUp_DropDayNumber = LastUp_DropDayNumber;
                            price.AddTime              = DateTime.Now;
                        }
                    }
                    else
                    {
                        if (PriceType == 2)
                        {
                            price.PriceType            = PriceType;
                            price.BusinessTime         = BusinessTime.AddDays(i);
                            price.UpPrice              = OpenMoney + Price * (i - 1);
                            price.OpenMoney            = OpenMoney + Price * (i);
                            price.Price                = Price;
                            price.Up_DropDayNumber     = Up_DropDayNumber - 1 - i;
                            price.LastOpenMoney        = lastOpenMoney + Price * (i);
                            price.LastUp_DropDayNumber = LastUp_DropDayNumber;
                            price.AddTime              = DateTime.Now;
                        }
                        else
                        {
                            price.PriceType            = PriceType;
                            price.BusinessTime         = BusinessTime.AddDays(i);
                            price.UpPrice              = OpenMoney - Price * (i - 1);
                            price.OpenMoney            = OpenMoney - Price * (i);
                            price.Price                = Price;
                            price.Up_DropDayNumber     = Up_DropDayNumber - 1 - i;
                            price.LastOpenMoney        = lastOpenMoney - Price * (i);
                            price.LastUp_DropDayNumber = LastUp_DropDayNumber;
                            price.AddTime              = DateTime.Now;
                        }
                    }
                    if (gp_priceBLL.Add(price) > 0)
                    {
                        DbHelperSQL.GetSingle(" exec gp_jiaoyiliang");
                        flag = true;
                    }
                }
                if (flag == true)
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('提交成功!');", true);
                    bind();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('提交失败!');", true);
                }
            }
        }