Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void UpdateBankMoney(BankMoneyInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbBankMoneyInfo set ");
            strSql.Append("BankID=@BankID,");
            strSql.Append("bMoney=@bMoney,");
            strSql.Append("bUpdateTime=@bUpdateTime,");
            strSql.Append("bAppendTime=@bAppendTime,");
            strSql.Append("isBegin=@isBegin");
            strSql.Append(" where BankMoneyID=@BankMoneyID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BankMoneyID", SqlDbType.Int,       4),
                new SqlParameter("@BankID",      SqlDbType.Int,       4),
                new SqlParameter("@bMoney",      SqlDbType.Money,     8),
                new SqlParameter("@bUpdateTime", SqlDbType.DateTime),
                new SqlParameter("@bAppendTime", SqlDbType.DateTime),
                new SqlParameter("@isBegin",     SqlDbType.Int,       4),
            };
            parameters[0].Value = model.BankMoneyID;
            parameters[1].Value = model.BankID;
            parameters[2].Value = model.bMoney;
            parameters[3].Value = model.bUpdateTime;
            parameters[4].Value = model.bAppendTime;
            parameters[5].Value = model.isBegin;

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

            strSql.Append("insert into tbBankMoneyInfo(");
            strSql.Append("BankID,bMoney,bUpdateTime,bAppendTime,isBegin)");
            strSql.Append(" values (");
            strSql.Append("@BankID,@bMoney,@bUpdateTime,@bAppendTime,@isBegin)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BankID",      SqlDbType.Int,       4),
                new SqlParameter("@bMoney",      SqlDbType.Money,     8),
                new SqlParameter("@bUpdateTime", SqlDbType.DateTime),
                new SqlParameter("@bAppendTime", SqlDbType.DateTime),
                new SqlParameter("@isBegin",     SqlDbType.Int,       4),
            };
            parameters[0].Value = model.BankID;
            parameters[1].Value = model.bMoney;
            parameters[2].Value = model.bUpdateTime;
            parameters[3].Value = model.bAppendTime;
            parameters[4].Value = model.isBegin;

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

            if (obj == null)
            {
                return(-1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BankMoneyInfo GetBankMoneyModel(DateTime bUpdateTime, int BankID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BankMoneyID,BankID,bMoney,bUpdateTime,bAppendTime,isBegin from tbBankMoneyInfo ");
            strSql.Append(" where BankID=@BankID and bUpdateTime=@bUpdateTime");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BankID",      SqlDbType.Int,      4),
                new SqlParameter("@bUpdateTime", SqlDbType.DateTime, 8)
            };
            parameters[0].Value = BankID;
            parameters[1].Value = bUpdateTime;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BankMoneyID"].ToString() != "")
                {
                    model.BankMoneyID = int.Parse(ds.Tables[0].Rows[0]["BankMoneyID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BankID"].ToString() != "")
                {
                    model.BankID = int.Parse(ds.Tables[0].Rows[0]["BankID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["bMoney"].ToString() != "")
                {
                    model.bMoney = decimal.Parse(ds.Tables[0].Rows[0]["bMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["bUpdateTime"].ToString() != "")
                {
                    model.bUpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["bUpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["bAppendTime"].ToString() != "")
                {
                    model.bAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["bAppendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isBegin"].ToString() != "")
                {
                    model.isBegin = int.Parse(ds.Tables[0].Rows[0]["isBegin"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        public DateTime sDate;//日期

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-2"))
                {
                    fList = tbBankInfo.GetBankList(" 1=1 order by bAppendTime desc").Tables[0];
                    Act   = HTTPRequest.GetString("Act");

                    fList.Columns.Add("money", typeof(decimal));

                    if (Act == "Edit")
                    {
                        sDate = DateTime.Parse(HTTPRequest.GetString("sDate"));
                        DataTable tDt = new DataTable();

                        tDt = tbBankMoneyInfo.GetBankMoneyList(" bUpdateTime='" + sDate + "'").Tables[0];
                        foreach (DataRow dr in tDt.Rows)
                        {
                            foreach (DataRow dr_x in fList.Rows)
                            {
                                if (dr_x["BankID"].ToString() == dr["BankID"].ToString())
                                {
                                    dr_x["money"] = dr["bMoney"];
                                }
                            }
                        }
                        fList.AcceptChanges();
                    }
                    if (ispost)
                    {
                        int      t           = 0;
                        DateTime bUpdateTime = DateTime.Parse(HTTPRequest.GetString("bUpdateTime"));

                        if (Act == "Add")
                        {
                            try
                            {
                                t = 0;
                                foreach (DataRow dr_x in fList.Rows)
                                {
                                    t++;
                                    if (HTTPRequest.GetString("Bank_" + t).Trim() != "")
                                    {
                                        BankMoneyInfo bmi = new BankMoneyInfo();
                                        bmi.BankID      = int.Parse(dr_x["BankID"].ToString());
                                        bmi.bMoney      = decimal.Parse(HTTPRequest.GetString("Bank_" + t));
                                        bmi.bUpdateTime = bUpdateTime;
                                        bmi.bAppendTime = DateTime.Now;

                                        tbBankMoneyInfo.AddBankMoney(bmi);
                                    }
                                }
                                AddMsgLine("添加成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            catch (Exception ex)
                            {
                                AddMsgLine("添加失败!<br/>" + ex);
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                        else if (Act == "Edit")
                        {
                            try
                            {
                                t = 0;
                                foreach (DataRow dr_x in fList.Rows)
                                {
                                    t++;
                                    if (HTTPRequest.GetString("Bank_" + t).Trim() != "")
                                    {
                                        BankMoneyInfo bmi = new BankMoneyInfo();
                                        bmi = tbBankMoneyInfo.GetBankMoneyModel(sDate, int.Parse(dr_x["BankID"].ToString()));
                                        if (bmi != null)
                                        {
                                            bmi.bMoney = decimal.Parse(HTTPRequest.GetString("Bank_" + t));
                                            tbBankMoneyInfo.UpdateBankMoney(bmi);
                                        }
                                        else
                                        {
                                            bmi             = new BankMoneyInfo();
                                            bmi.BankID      = int.Parse(dr_x["BankID"].ToString());
                                            bmi.bMoney      = decimal.Parse(HTTPRequest.GetString("Bank_" + t));
                                            bmi.bUpdateTime = bUpdateTime;
                                            bmi.bAppendTime = DateTime.Now;

                                            tbBankMoneyInfo.AddBankMoney(bmi);
                                        }
                                    }
                                }
                                AddMsgLine("修改成功!");
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                            catch (Exception ex)
                            {
                                AddMsgLine("修改失败!<br/>" + ex);
                                AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                            }
                        }
                    }
                    else
                    {
                        if (Act == "Del")
                        {
                            try
                            {
                                tbBankMoneyInfo.DeleteBankMoneyForDate(HTTPRequest.GetString("sDate"));
                                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.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
 public static void UpdateBankMoney(BankMoneyInfo model)
 {
     DatabaseProvider.GetInstance().UpdateBankMoney(model);
 }
 public static int AddBankMoney(BankMoneyInfo model)
 {
     return(DatabaseProvider.GetInstance().AddBankMoney(model));
 }