Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.Budget_Detail GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT top 1 [ID],[BudgetID],[Balance],[Unit],[Oldbalance],[KYbalance],[DetailName] FROM [dbo].[Budget_Detail] ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Dianda.Model.Budget_Detail model = new Dianda.Model.Budget_Detail();
            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 = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BudgetID"] != null && ds.Tables[0].Rows[0]["BudgetID"].ToString() != "")
                {
                    model.BudgetID = int.Parse(ds.Tables[0].Rows[0]["BudgetID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Balance"] != null && ds.Tables[0].Rows[0]["Balance"].ToString() != "")
                {
                    model.Balance = decimal.Parse(ds.Tables[0].Rows[0]["Balance"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Unit"] != null && ds.Tables[0].Rows[0]["Unit"].ToString() != "")
                {
                    model.Unit = int.Parse(ds.Tables[0].Rows[0]["Unit"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Oldbalance"] != null && ds.Tables[0].Rows[0]["Oldbalance"].ToString() != "")
                {
                    model.Oldbalance = decimal.Parse(ds.Tables[0].Rows[0]["Oldbalance"].ToString());
                }
                if (ds.Tables[0].Rows[0]["KYbalance"] != null && ds.Tables[0].Rows[0]["KYbalance"].ToString() != "")
                {
                    model.KYbalance = decimal.Parse(ds.Tables[0].Rows[0]["KYbalance"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DetailName"] != null && ds.Tables[0].Rows[0]["DetailName"].ToString() != "")
                {
                    model.DetailName = ds.Tables[0].Rows[0]["DetailName"].ToString();
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Dianda.Model.Budget_Detail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Budget_Detail set ");
            strSql.Append("BudgetID=@BudgetID,");
            strSql.Append("Balance=@Balance,");
            strSql.Append("Unit=@Unit,");
            strSql.Append("Oldbalance=@Oldbalance,");
            strSql.Append("KYbalance=@KYbalance,");
            strSql.Append("DetailName=@DetailName ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BudgetID",   SqlDbType.Int,   4),
                new SqlParameter("@Balance",    SqlDbType.Float, 8),
                new SqlParameter("@Unit",       SqlDbType.Int,   4),
                new SqlParameter("@Oldbalance", SqlDbType.Float, 8),
                new SqlParameter("@KYbalance",  SqlDbType.Float, 8),
                new SqlParameter("@ID",         SqlDbType.Int,   4),
                new SqlParameter("@DetailName", SqlDbType.NVarChar)
            };
            parameters[0].Value = model.BudgetID;
            parameters[1].Value = model.Balance;
            parameters[2].Value = model.Unit;
            parameters[3].Value = model.Oldbalance;
            parameters[4].Value = model.KYbalance;
            parameters[5].Value = model.ID;
            parameters[6].Value = model.DetailName;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Dianda.Model.Budget_Detail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Budget_Detail(");
            strSql.Append("[BudgetID],[Balance],[Unit],[Oldbalance],[KYbalance],[DetailName])");
            strSql.Append(" values (");
            strSql.Append("@BudgetID,@Balance,@Unit,@Oldbalance,@KYbalance,@DetailName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BudgetID",   SqlDbType.Int,   4),
                new SqlParameter("@Balance",    SqlDbType.Float, 8),
                new SqlParameter("@Unit",       SqlDbType.Int,   4),
                new SqlParameter("@Oldbalance", SqlDbType.Float, 8),
                new SqlParameter("@KYbalance",  SqlDbType.Float, 8),
                new SqlParameter("@DetailName", SqlDbType.NVarChar)
            };
            parameters[0].Value = model.BudgetID;
            parameters[1].Value = model.Balance;
            parameters[2].Value = model.Unit;
            parameters[3].Value = model.Oldbalance;
            parameters[4].Value = model.KYbalance;
            parameters[5].Value = model.DetailName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        ///点击确定按钮触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button_sumbit_Click(object sender, EventArgs e)
        {
            try
            {
                //经费调整说明
                string  NAME  = "";
                decimal money = 0;
                //登录用户
                Model.USER_Users user_model = (Model.USER_Users)Session["USER_Users"];
                budgetUserApply.RoundNO = Guid.NewGuid().ToString();

                foreach (GridViewRow item in GridView1.Rows)
                {
                    Label       la          = (Label)item.FindControl("Label_Name");
                    TextBox     tx          = (TextBox)item.FindControl("txtBalance");
                    Label       lb          = (Label)item.FindControl("LB_Balance");
                    HiddenField HF_DetailID = (HiddenField)item.FindControl("HF_DetailID");
                    string      ID          = GridView1.DataKeys[item.RowIndex].Value.ToString();
                    string      cashmoney   = "";

                    Model.Budget_Detail budgetDetail    = new Dianda.Model.Budget_Detail();
                    BLL.Budget_Detail   budgetDetailBll = new Dianda.BLL.Budget_Detail();
                    budgetDetail = budgetDetailBll.GetModel(int.Parse(HF_DetailID.Value));

                    if (rblDoType.SelectedValue == "2")
                    {
                        //if (double.Parse(tx.Text.ToString()) > double.Parse(lb.Text.ToString()))
                        //{
                        //    tag.Text = la.Text + "减少的金额不能大于可用金额!";
                        //    tag2.Text = la.Text + "减少的金额不能大于可用金额!";
                        //    return;
                        //}

                        if (decimal.Parse(tx.Text) == 0)
                        {
                            cashmoney = tx.Text;
                        }
                        else
                        {
                            cashmoney = "-" + tx.Text;
                        }
                        //在原来该细目的可用金额基础上减去输入的值 
                        budgetDetail.KYbalance = Decimal.Parse(budgetDetail.KYbalance.ToString()) - Decimal.Parse(tx.Text.ToString());
                        //budgetDetail.Balance = Decimal.Parse(budgetDetail.Balance.ToString()) - Decimal.Parse(tx.Text.ToString());
                        budgetDetailBll.Update(budgetDetail);
                    }
                    else
                    {
                        cashmoney = tx.Text;
                        //在原来该细目的可用金额基础上加上输入的值 
                        budgetDetail.KYbalance = Decimal.Parse(budgetDetail.KYbalance.ToString()) + Decimal.Parse(tx.Text.ToString());
                        //budgetDetail.Balance = Decimal.Parse(budgetDetail.Balance.ToString()) + Decimal.Parse(tx.Text.ToString());
                        budgetDetailBll.Update(budgetDetail);
                    }

                    //记录用户记账明细
                    budgetUserApply.BudgetID   = budgetDetail.BudgetID;
                    budgetUserApply.DetailID   = budgetDetail.ID;
                    budgetUserApply.DetailName = budgetDetail.DetailName;
                    budgetUserApply.DoUserID   = user_model.ID;
                    budgetUserApply.Balance    = this.rblDoType.SelectedValue == "1" ?
                                                 Decimal.Parse(tx.Text) :
                                                 Decimal.Parse(tx.Text) * -1;
                    budgetUserApply.AddTime = DateTime.Now;
                    budgetUserApplyBll.Add(budgetUserApply);

                    //拼接controlInfo
                    NAME  += ID + "," + la.Text + "," + cashmoney + "|";
                    money += decimal.Parse(tx.Text);
                }
                NAME = NAME.Remove(NAME.LastIndexOf("|"));
                if (String.IsNullOrEmpty(NAME))
                {
                    tag.Text  = "调整说明不能为空,请填写调整说明!";
                    tag2.Text = "调整说明不能为空,请填写调整说明!";
                    return;
                }
                // budget = new Dianda.Model.Budget();
                budget                      = budgetBll.GetModel(Int32.Parse(common.cleanXSS(Request["ID"]))); //Cash_Cards的ID)
                budgetApplyHistory          = new Dianda.Model.Budget_Apply_History();
                budgetApplyHistory.BudgetID = Int32.Parse(common.cleanXSS(Request["ID"]));                     //Cash_Cards的ID
                //mCash_Apply_History.ControlInfo = this.txtControlInfo.Text;
                //资金调整说明
                budgetApplyHistory.ControlInfo = NAME;
                if (this.rblDoType.SelectedValue == "1")                //增加
                {
                    budgetApplyHistory.Balance = Decimal.Parse(this.lblBalance.Text) + money;
                }
                else                //减少
                {
                    budgetApplyHistory.Balance = Decimal.Parse(this.lblBalance.Text) - money;
                }
                budgetApplyHistory.DATETIME = DateTime.Now;
                budgetApplyHistory.DoUser   = ((Model.USER_Users)Session["USER_Users"]).USERNAME;
                budgetApplyHistory.DoType   = rblDoType.SelectedValue == "1" ? "增加" + money + "元" : "减少" + money + "元";
                budgetApplyHistory.NOTES    = TextBox1.Text;
                budgetApplyHistoryBll.Add(budgetApplyHistory);

                //string oldLimitNums = budget.LimitNums.ToString();

                budgetBll.Update(budget);
                //this.ucshow1.BindData();
                Read_Data(common.cleanXSS(Request["id"].ToString()));

                /*给业务申请者发信息*/
                //Model.FaceShowMessage mFaceShowMessage = new Dianda.Model.FaceShowMessage();
                //BLL.FaceShowMessage bFaceShowMessage = new Dianda.BLL.FaceShowMessage();

                //mFaceShowMessage.DATETIME = DateTime.Now;
                //mFaceShowMessage.FromTable = "经费";
                //mFaceShowMessage.IsRead = 0;
                //mFaceShowMessage.NewsID = null;
                //mFaceShowMessage.NewsType = "经费";
                //mFaceShowMessage.ReadTime = null;
                //mFaceShowMessage.Receive = mCash_Cards.CardholderID;
                //mFaceShowMessage.DELFLAG = 0;
                //mFaceShowMessage.URLS = ((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME.ToString() + ")调整了您的资金卡[" + mCash_Cards.CardName + "]!<a href='/Admin/cashCardManage/showHistory.aspx?id=" + Request["ID"] + "' target='_self' title='操作记录查看'>点击查看</a>";
                //bFaceShowMessage.Add(mFaceShowMessage);
                /*给业务申请者发信息*/

                tag.Text  = "操作成功!";
                tag2.Text = "操作成功!";

                //添加操作日志
                Dianda.BLL.SYS_LogsExt bsyslog = new Dianda.BLL.SYS_LogsExt();
                bsyslog.addlogs(((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME + ")", "待办预算调整", "待办预算" + ((rblDoType.SelectedValue == "1") ? "增加" : "减少") + money + "成功");
                //添加操作日志

                if (((Button)sender).ID == "Button_sumbit")
                {
                    string coutws = "<script language=\"javascript\" type=\"text/javascript\">alert(\"操作成功!现在进入明细页面\"); ";
                    if (PageStr == "add")
                    {
                        coutws += "location.href = \"" + _PageAdd1 + ReturnCS() + "\";</script>";
                    }
                    else
                    {
                        coutws += "location.href = \"showHistory.aspx?id=" + common.cleanXSS(Request["id"]) + "&PageRole=manage\";</script>";
                    }
                    Response.Write(coutws);
                }
                else
                {
                    //foreach (GridViewRow item1 in GridView1.Rows)
                    //{
                    //    TextBox tx = (TextBox)item1.FindControl("txtBalance");
                    //    tx.Text = "0";

                    //}
                    ShowDDLControlInfo(common.cleanXSS(Request["id"]));
                    TextBox1.Text = "";
                    //tag.Text = "";
                }
            }
            catch (Exception ex)
            {
                tag.Text  = "操作失败,请重试!";
                tag2.Text = "操作失败,请重试!";
            }
        }