示例#1
0
        /// <summary>
        /// 添加学生资助类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Add_Click(object sender, EventArgs e)
        {
            lab_Error.Text = "";
            SubsidyForEmployee model = new SubsidyForEmployee();
            try
            {
                model.SubsidyName = txt_SubsidyName.Text.Trim();
                model.SubsidyDescription = txt_SubsidyDescription.Text.Trim();
                model.BeginDate = DateTime.Now;
                List<SubsidyForEmployee> temp = SubsidyForEmployee.IsExists(0, model.SubsidyName) as List<SubsidyForEmployee>;

                if (temp.Count > 0)
                {
                    lab_Error.Text = "补助类别编号已存在";
                    return;
                }
                model.Save();
                Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('添加成功');", true);
                BindData();
                txt_SubsidyDescription.Text = "";
                txt_SubsidyName.Text = "";
            }
            catch (Exception ex)
            {
                lab_Error.Text = "错误信息:" + ex.Message;
            }
        }
示例#2
0
        //修改
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            lab_Error.Text = "";
            SubsidyForEmployee model = new SubsidyForEmployee();
            try
            {
                if (hid_typeId.Value!= null)
                {
                    model = SubsidyForEmployee.Load(Convert.ToInt32(hid_typeId.Value));
                }

                model.SubsidyName = txt_SubsidyName.Text.Trim();
                model.SubsidyDescription = txt_SubsidyDescription.Text.Trim();
                List<SubsidyForEmployee> temp = SubsidyForEmployee.IsExists(model.Id, model.SubsidyName) as List<SubsidyForEmployee>;

                if (temp.Count > 0)
                {
                    lab_Error.Text = "补助类别编号已存在";
                    return;
                }
                    model.Save();
                    hid_typeId.Value = "";
                    Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('修改成功');", true);
                    BindData();

                  btn_Add.Visible = true;
                  btn_Update.Visible = false;
                  btn_AddSubsidyType.Text = "添加补助类别";
                  btn_Cancel_Click(sender, e);

            }
            catch (Exception ex)
            {
                hid_typeId.Value = "";
                lab_Error.Text = "错误信息:" + ex.Message;
            }
        }