Esempio n. 1
0
        /// <summary>
        /// 加载当前数据
        /// </summary>
        private void LoadNowMoney()
        {
            int    id       = Convert.ToInt32(Request.QueryString["id"]);
            string itemname = Request.QueryString["itemname"];

            AusMoney ausmoney = AusMoneyManager.GetModel(id);

            this.person.SelectedValue = ausmoney.username;
            this.txtmoney.Text        = ausmoney.amount.ToString();
            this.person.Enabled       = false;
        }
Esempio n. 2
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ibtnUpdate_Click(object sender, ImageClickEventArgs e)
        {
            int    id       = Convert.ToInt32(Request.QueryString["id"]);
            string itemname = Request.QueryString["itemname"];

            AusMoney ausmoney = AusMoneyManager.GetModel(id);
            double   haspay   = ausmoney.haspay;

            if (Convert.ToDouble(this.txtmoney.Text.Trim()) < haspay)
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "error", "<script>alert('更新失败,该人员在该项目下的总预算不能小于已支付的预算')</script>", false);
            }
            if (this.txtmoney.Text != "")
            {
                //bool has = AusMoneyManager.Exists(itemname, this.person.SelectedValue);
                //if (has)
                //{
                //    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "error", "<script>alert('更新失败,该人员在该项目下已存在预算')</script>", false);
                //}
                //else
                //{
                //ausmoney.username = this.person.SelectedValue;
                ausmoney.amount = Convert.ToDouble(this.txtmoney.Text.Trim());
                bool count = AusMoneyManager.Update(ausmoney);
                if (count)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "success", "<script>alert('更新成功');window.location='DepartMoneyList.aspx?itemname=" + itemname + "';</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('更新失败')</script>", false);
                }
                //}
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "alert('请检查人员和金额是否已经填写');", true);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ibtnAdd_Click(object sender, ImageClickEventArgs e)
        {
            string itemname = Request.QueryString["itemname"];
            string username = this.person.SelectedValue;
            int    year     = DateTime.Now.Year;

            if (this.person.SelectedIndex != 0 && this.txtmoney.Text != "")
            {
                if (AusMoneyManager.Exists(itemname, username, year))
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "error", "<script>alert('添加失败,该人员在该项目下已存在预算')</script>", false);
                }
                else
                {
                    AusMoney ausmoney = new AusMoney();
                    ausmoney.itemname = itemname;
                    ausmoney.username = username;
                    ausmoney.amount   = double.Parse(this.txtmoney.Text.Trim());
                    ausmoney.year     = year;

                    bool count = AusMoneyManager.Add(ausmoney);
                    if (count)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "success", "<script>alert('添加成功');window.location='DepartMoneyList.aspx?itemname=" + itemname + "';</script>", false);
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('添加失败')</script>", false);
                    }
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "alert('请检查人员和金额是否已经填写');", true);
            }
        }
        /// <summary>
        /// 编辑删除
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void moneylist_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id       = e.CommandArgument.ToString();
            string itemname = Request.QueryString["itemname"];

            switch (e.CommandName)
            {
            case "Update":
                Response.Redirect("UpdateAusMoney.aspx?id=" + id + "&itemname=" + itemname);
                break;

            case "Delete":
                bool del = AusMoneyManager.Delete(Convert.ToInt32(id));
                if (del)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "success", "<script>alert('删除成功');window.location='DepartMoneyList.aspx?itemname=" + this.hiditem.Value + "';</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('删除失败')</script>", true);
                }
                break;
            }
        }