/// <summary> /// 根据给定的股票ID,更新A盘可提现余额(0为提现,1为取消提现) /// </summary> /// <param name="iStockID">给定的股票ID</param> /// <param name="dMoney">提现数额</param> /// <param name="dCurrentPrice">当前股价</param> /// <param name="iType">0为提现,1为取消提现</param> /// <returns></returns> public bool UpdateStockNumber(long iStockID, decimal dMoney, decimal dCurrentPrice, int iType) { decimal dAmount = Convert.ToDecimal("0.00"); decimal dProfit = Convert.ToDecimal("0.00"); lgk.Model.tb_Stock stockInfo = GetModel(iStockID); if (stockInfo != null) { dAmount = stockInfo.Number * dCurrentPrice;//股票*当前股价=当前金额 if (iType == 0) { dProfit = dAmount - dMoney; } else { dProfit = dAmount + dMoney; } stockInfo.Number = Convert.ToInt32(Math.Round(dProfit / dCurrentPrice, 0)); return(Update(stockInfo)); } else { return(false); } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { long iStockID = Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "StockID")); Literal ltIsBuy = (Literal)e.Item.FindControl("ltIsBuy"); lgk.Model.tb_Stock stockInfo = stockBLL.GetModel(iStockID); if (stockInfo.IsSell == 0)//0持有,1挂单,2已生成订单卖出中,3已卖出 { ltIsBuy.Text = "持有"; } else if (stockInfo.IsSell == 1) { ltIsBuy.Text = "挂单"; } else if (stockInfo.IsSell == 2) { ltIsBuy.Text = "卖出中"; } else if (stockInfo.IsSell == 3) { ltIsBuy.Text = "已卖出"; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_Stock model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Stock set "); strSql.Append(" UserID = @UserID,"); strSql.Append(" Amount = @Amount,"); strSql.Append(" BuyPrice = @BuyPrice,"); strSql.Append(" Price = @Price,"); strSql.Append(" Number = @Number,"); strSql.Append(" Surplus = @Surplus,"); strSql.Append(" SplitNum = @SplitNum,"); strSql.Append(" BuyDate = @BuyDate,"); strSql.Append(" IsLock = @IsLock,"); strSql.Append(" IsSell = @IsSell"); strSql.Append(" where StockID=@StockID "); SqlParameter[] parameters = { new SqlParameter("@StockID", SqlDbType.BigInt, 8), new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Decimal, 9), new SqlParameter("@BuyPrice", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Number", SqlDbType.Int, 4), new SqlParameter("@Surplus", SqlDbType.Int, 4), new SqlParameter("@SplitNum", SqlDbType.Int, 4), new SqlParameter("@BuyDate", SqlDbType.DateTime), new SqlParameter("@IsLock", SqlDbType.Int, 4), new SqlParameter("@IsSell", SqlDbType.Int, 4) }; parameters[0].Value = model.StockID; parameters[1].Value = model.UserID; parameters[2].Value = model.Amount; parameters[3].Value = model.BuyPrice; parameters[4].Value = model.Price; parameters[5].Value = model.Number; parameters[6].Value = model.SplitNum; parameters[7].Value = model.Surplus; parameters[8].Value = model.BuyDate; parameters[9].Value = model.IsLock; parameters[10].Value = model.IsSell; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(lgk.Model.tb_Stock model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Stock("); strSql.Append("UserID,Amount,BuyPrice,Price,Number,Surplus,SplitNum,BuyDate,IsLockIsSell"); strSql.Append(") values ("); strSql.Append("@UserID,@Amount,@BuyPrice,@Price,@Number,@Surplus,@SplitNum,@BuyDate,@IsLock@IsSell"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Decimal, 9), new SqlParameter("@BuyPrice", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Number", SqlDbType.Int, 4), new SqlParameter("@Surplus", SqlDbType.Int, 4), new SqlParameter("@SplitNum", SqlDbType.Int, 4), new SqlParameter("@BuyDate", SqlDbType.DateTime), new SqlParameter("@IsLock", SqlDbType.Int, 4), new SqlParameter("@IsSell", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.Amount; parameters[2].Value = model.BuyPrice; parameters[3].Value = model.Price; parameters[4].Value = model.Number; parameters[5].Value = model.Surplus; parameters[6].Value = model.SplitNum; parameters[7].Value = model.BuyDate; parameters[8].Value = model.IsLock; parameters[9].Value = model.IsSell; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(long.Parse(obj.ToString())); } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { int iUserID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "UserID")); int iStockID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "StockID")); //会员编号 Literal ltUserCode = (Literal)e.Item.FindControl("ltUserCode"); Literal ltTrueName = (Literal)e.Item.FindControl("ltTrueName"); Literal ltProfit = (Literal)e.Item.FindControl("ltProfit"); lgk.Model.tb_Stock stockInfo = stockBLL.GetModel(iStockID); ltProfit.Text = Convert.ToString(stockInfo.Number * (getParamAmount("shares5") - stockInfo.Price)); lgk.Model.tb_user userInfo = userBLL.GetModel(iUserID); ltUserCode.Text = userInfo.UserCode; ltTrueName.Text = userInfo.TrueName; } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_Stock GetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StockID, UserID, Amount, BuyPrice, Price, Number, Surplus, SplitNum, BuyDate, IsLock, IsSell"); strSql.Append(" from tb_Stock "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } lgk.Model.tb_Stock model = new lgk.Model.tb_Stock(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["StockID"].ToString() != "") { model.StockID = long.Parse(ds.Tables[0].Rows[0]["StockID"].ToString()); } if (ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["Amount"].ToString() != "") { model.Amount = decimal.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()); } if (ds.Tables[0].Rows[0]["BuyPrice"].ToString() != "") { model.BuyPrice = decimal.Parse(ds.Tables[0].Rows[0]["BuyPrice"].ToString()); } if (ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Number"].ToString() != "") { model.Number = int.Parse(ds.Tables[0].Rows[0]["Number"].ToString()); } if (ds.Tables[0].Rows[0]["Surplus"].ToString() != "") { model.Surplus = int.Parse(ds.Tables[0].Rows[0]["Surplus"].ToString()); } if (ds.Tables[0].Rows[0]["SplitNum"].ToString() != "") { model.SplitNum = int.Parse(ds.Tables[0].Rows[0]["SplitNum"].ToString()); } if (ds.Tables[0].Rows[0]["BuyDate"].ToString() != "") { model.BuyDate = DateTime.Parse(ds.Tables[0].Rows[0]["BuyDate"].ToString()); } if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "") { model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString()); } if (ds.Tables[0].Rows[0]["IsSell"].ToString() != "") { model.IsSell = int.Parse(ds.Tables[0].Rows[0]["IsSell"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_Stock GetModel(long StockID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select StockID, UserID, Amount, BuyPrice, Price, Number, Surplus, SplitNum, BuyDate, IsLock, IsSell"); strSql.Append(" from tb_Stock"); strSql.Append(" where StockID=@StockID"); SqlParameter[] parameters = { new SqlParameter("@StockID", SqlDbType.BigInt, 8) }; parameters[0].Value = StockID; lgk.Model.tb_Stock model = new lgk.Model.tb_Stock(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["StockID"].ToString() != "") { model.StockID = long.Parse(ds.Tables[0].Rows[0]["StockID"].ToString()); } if (ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["Amount"].ToString() != "") { model.Amount = decimal.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()); } if (ds.Tables[0].Rows[0]["BuyPrice"].ToString() != "") { model.BuyPrice = decimal.Parse(ds.Tables[0].Rows[0]["BuyPrice"].ToString()); } if (ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Number"].ToString() != "") { model.Number = int.Parse(ds.Tables[0].Rows[0]["Number"].ToString()); } if (ds.Tables[0].Rows[0]["Surplus"].ToString() != "") { model.Surplus = int.Parse(ds.Tables[0].Rows[0]["Surplus"].ToString()); } if (ds.Tables[0].Rows[0]["SplitNum"].ToString() != "") { model.SplitNum = int.Parse(ds.Tables[0].Rows[0]["SplitNum"].ToString()); } if (ds.Tables[0].Rows[0]["BuyDate"].ToString() != "") { model.BuyDate = DateTime.Parse(ds.Tables[0].Rows[0]["BuyDate"].ToString()); } if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "") { model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString()); } if (ds.Tables[0].Rows[0]["IsSell"].ToString() != "") { model.IsSell = int.Parse(ds.Tables[0].Rows[0]["IsSell"].ToString()); } return(model); } else { return(null); } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { int ID = Convert.ToInt32(e.CommandArgument); //ID lgk.Model.tb_takeMoney takeMoneyInfo = takeBLL.GetModel(ID); lgk.BLL.tb_systemMoney sy = new lgk.BLL.tb_systemMoney(); lgk.Model.tb_systemMoney system = sy.GetModel(1); if (takeMoneyInfo == null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该记录已删除,无法再进行此操作!');window.location.href='TakeMoney.aspx';", true); } else { if (takeMoneyInfo.Flag == 1) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('该记录已审核,无法再进行此操作!');window.location.href='TakeMoney.aspx';", true); } else { lgk.Model.tb_Stock stockInfo = stockBLL.GetModel("UserID=" + takeMoneyInfo.UserID); lgk.Model.tb_user userInfo = userBLL.GetModel(Convert.ToInt32(takeMoneyInfo.UserID)); decimal dProfit = stockInfo.Number * (getParamAmount("shares5") - stockInfo.Price); if (e.CommandName.Equals("Open"))//确认 { takeMoneyInfo.Flag = 1; takeMoneyInfo.Take006 = DateTime.Now; if (takeBLL.Update(takeMoneyInfo) && UpdateSystemAccount("MoneyAccount", Convert.ToDecimal(takeMoneyInfo.RealityMoney), 0) > 0) { //发送短信通知 string content = GetLanguage("MessageTakeMoneyOK").Replace("{username}", userInfo.UserCode).Replace("{time}", Convert.ToDateTime(takeMoneyInfo.TakeTime).ToString("yyyy年MM月dd日HH时mm分")).Replace("{timeEn}", Convert.ToDateTime(takeMoneyInfo.TakeTime).ToString("yyyy/MM/dd HH:mm")); SendMessage(Convert.ToInt32(takeMoneyInfo.UserID), userInfo.PhoneNum, content); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('操作成功!');window.location.href='TakeMoney.aspx';", true); } } if (e.CommandName.Equals("Remove"))//删除 { //加入流水账表 lgk.Model.tb_journal model = new lgk.Model.tb_journal(); model.UserID = takeMoneyInfo.UserID; model.Remark = "取消提现"; model.InAmount = takeMoneyInfo.TakeMoney; model.OutAmount = 0; model.BalanceAmount = dProfit + takeMoneyInfo.TakeMoney; model.JournalDate = DateTime.Now; model.JournalType = 1; model.Journal01 = takeMoneyInfo.UserID; bool bFalg = stockBLL.UpdateStockNumber(stockInfo.StockID, Convert.ToDecimal(takeMoneyInfo.TakeMoney), getParamAmount("shares5"), 1); if (journalBLL.Add(model) > 0 && bFalg && takeBLL.Delete(ID)) { MessageBox.MyShow(this, "取消成功"); BindData(); } else { MessageBox.MyShow(this, "取消失败"); } } } } }