protected void Save_OnClick(object sender, EventArgs e) { #region 验证 if(NumbersTBX.Text.Trim()=="") { LabMS.Common.JShelper.JSAlert(Page, "err", "分类号码不能为空!"); return; } if(NumTBX.Text.Trim()=="") { LabMS.Common.JShelper.JSAlert(Page, "err", "购买数量不能为空!"); return; } #endregion LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); LabMS.Model.BuyApp buyAppModel = new LabMS.Model.BuyApp(); buyAppModel.ClassNumber = NumbersTBX.Text.Trim();//分类号码 buyAppModel.Name = NameTBX.Text.Trim();//编号名称 if (NumbersTBX.Text.Trim() != "") { int iNum; if (int.TryParse(NumTBX.Text.Trim(), out iNum)) { buyAppModel.Numbers = iNum.ToString();//购买数量 } else { LabMS.Common.JShelper.JSAlert(Page, "err", "购买数量只能为不小于0整数!"); return; } } buyAppModel.Type = TypeDDL.SelectedValue;//类型 Button btn = (Button)sender; string strID = btn.ID; if (strID == "SaveBtn") { buyAppModel.State = "0";//状态 } else { buyAppModel.State = "1";//状态 buyAppModel.AppPerson=UserRealName; buyAppModel.AppTime = DateTime.Now;//日期 } buyAppModel.AppComment = LabMS.Common.codehelper.Encode(AppCommentTBX.Text.Trim());//申请备注 try { buyAppBLL.Add(buyAppModel); LabMS.Common.JShelper.JSAlertAndRedirect(Page, "success", "添加成功!", "buyapp.aspx"); } catch { LabMS.Common.JShelper.JSAlert(Page, "err", "添加失败,请重新添加!"); } }
//申请 protected void AppBtn_Click(object sender, EventArgs e) { LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); LabMS.Model.BuyApp buyAppModel = new LabMS.Model.BuyApp(); Button btn = (Button)sender; string strBtnID = btn.ID; string strAlert=""; if (IDHF.Value != "") { int ID; if (int.TryParse(IDHF.Value, out ID)) { buyAppModel = buyAppBLL.GetModel(ID); if (strBtnID == "AppBtn") { buyAppModel.State = "1"; strAlert = "申请成功,请等待审核!"; } else if (strBtnID == "ConAppBtn") { buyAppModel.State = "0"; strAlert = "撤销申请成功!"; } else if (strBtnID == "PassAppBtn") { buyAppModel.State = "3"; strAlert = "审核成功!"; buyAppModel.VerifyComment = LabMS.Common.codehelper.Encode(VerifyComment.Text.Trim());//审核备注 buyAppModel.VerifyTime = DateTime.Now; buyAppModel.VerifyPerson=UserRealName;//审核人 Session获取 } else if (strBtnID == "UnPassAppBtn") { buyAppModel.State = "2"; strAlert = "拒绝成功!"; buyAppModel.VerifyComment = LabMS.Common.codehelper.Encode(VerifyComment.Text.Trim());//审核备注 buyAppModel.VerifyTime = DateTime.Now; //buyAppModel.VerifyPerson=;//审核人 Session获取 } buyAppBLL.Update(buyAppModel); LabMS.Common.JShelper.JSAlertAndRedirect(Page,"err",strAlert,"buyappperview.aspx?ID=" + ID); return; } } LabMS.Common.JShelper.JSAlert(Page, "err", "操作失败!"); return; }
//绑定GridView protected void BuyAppGridView_DataBind() { LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); List<LabMS.Model.BuyApp> buyAppModelList = new List<LabMS.Model.BuyApp>(); string strWhere = GetSearchInfo(); if (UserType == "teacher") { strWhere = " AppPerson='" + UserRealName + "'"; } buyAppModelList = buyAppBLL.GetModelList(strWhere); BuyAppGridView.DataSource = HandleList(buyAppModelList); BuyAppGridView.DataBind(); }
//删除 protected void DelBtn_Click(object sender, EventArgs e) { LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); if (IDHF.Value != "") { int ID; if (int.TryParse(IDHF.Value, out ID)) { buyAppBLL.Delete(ID); LabMS.Common.JShelper.JSAlertAndRedirect(Page, "err", "删除成功!", "buyapplist.aspx"); return; } } LabMS.Common.JShelper.JSAlert(Page, "err", "删除失败!"); return; }
protected void Page_Load(object sender, EventArgs e) { strPagePrivilege.Add("GMSQSH");//必须写在ispostback外 strPageUserType.Add("mana"); strPageUserType.Add("teacher"); if (Request.QueryString["ID"] != null) { if (!IsPostBack) { int ID; if (int.TryParse(Request.QueryString["ID"].ToString(), out ID)) { try { IDHF.Value = ID.ToString(); LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); LabMS.Model.BuyApp buyAppModel = new LabMS.Model.BuyApp(); buyAppModel = buyAppBLL.GetModel(ID); AppCommentLbl.Text = LabMS.Common.codehelper.Decode(buyAppModel.AppComment);//申请备注 NumbersLbl.Text = buyAppModel.ClassNumber;//分类号码 NameLbl.Text = buyAppModel.Name;//仪器名称 NumLbl.Text = buyAppModel.Numbers;//购买数量 TypeDDL.SelectedValue = buyAppModel.Type;//类型 VerifyPerson.Text = buyAppModel.VerifyPerson; VerifyTime.Text = buyAppModel.VerifyTime.ToString();//审核日期 lbVerifyComment.Text = LabMS.Common.codehelper.Decode(buyAppModel.VerifyComment);//审核备注 iniBtn(buyAppModel.State); } catch { ERRLbl.Text = "该购买申请不存在!"; ERRLbl.Visible = true; AppBtn.Visible = false; DelBtn.Visible = false; mondifybtn.Visible = false; ConAppBtn.Visible = false; PassAppBtn.Visible = false; UnPassAppBtn.Visible = false; } } else { ERRLbl.Text = "系统异常,参数不合法!"; ERRLbl.Visible = true; AppBtn.Visible = false; DelBtn.Visible = false; mondifybtn.Visible = false; ConAppBtn.Visible = false; PassAppBtn.Visible = false; UnPassAppBtn.Visible = false; } } } else { ERRLbl.Text = "系统异常,参数为空!"; ERRLbl.Visible = true; AppBtn.Visible = false; DelBtn.Visible = false; mondifybtn.Visible = false; ConAppBtn.Visible = false; PassAppBtn.Visible = false; UnPassAppBtn.Visible = false; } }
//删除 protected void Delete_OnClick(object sender, EventArgs e) { LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); int count = BuyAppGridView.Rows.Count; for (int i = 0; i < count; i++) { CheckBox CBTemp = (CheckBox)BuyAppGridView.Rows[i].FindControl("chk"); if (CBTemp.Checked) { try { buyAppBLL.Delete(int.Parse(BuyAppGridView.DataKeys[i].Value.ToString())); } catch (Exception ex) { throw ex; } } } }
protected void Page_Load(object sender, EventArgs e) { strPageUserType.Add("teacher"); if (Request.QueryString["ID"] != null) { if (!IsPostBack) { int ID; if (int.TryParse(Request.QueryString["ID"].ToString(), out ID)) { try { IDHF.Value = ID.ToString(); LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); LabMS.Model.BuyApp buyAppModel = new LabMS.Model.BuyApp(); buyAppModel = buyAppBLL.GetModel(ID); AppCommentTBX.Text = LabMS.Common.codehelper.Decode(buyAppModel.AppComment);//申请备注 NumbersTBX.Text = buyAppModel.ClassNumber;//分类号码 NameTBX.Text = buyAppModel.Name;//仪器名称 NumTBX.Text = buyAppModel.Numbers;//购买数量 TypeDDL.SelectedValue = buyAppModel.Type;//类型 } catch { ERRLbl.Text = "该购买申请不存在!"; ERRLbl.Visible = true; SubmitBtn.Visible = false; ModifyBtn.Visible = false; } } else { ERRLbl.Text = "系统异常,参数不合法!"; ERRLbl.Visible = true; SubmitBtn.Visible = false; ModifyBtn.Visible = false; } } } else { ERRLbl.Text = "系统异常,参数为空!"; ERRLbl.Visible = true; SubmitBtn.Visible = false; ModifyBtn.Visible = false; } }
protected void Modify_OnClick(object sender, EventArgs e) { #region 验证 if (NumbersTBX.Text.Trim() == "") { LabMS.Common.JShelper.JSAlert(Page, "err", "分类号码不能为空!"); return; } if (NumTBX.Text.Trim() == "") { LabMS.Common.JShelper.JSAlert(Page, "err", "购买数量不能为空!"); return; } if (IDHF.Value == "") { LabMS.Common.JShelper.JSAlert(Page, "err", "参数丢失,请重新打开修改页面!"); return; } #endregion LabMS.BLL.BuyApp buyAppBLL = new LabMS.BLL.BuyApp(); LabMS.Model.BuyApp buyAppModel = new LabMS.Model.BuyApp(); Button btn = (Button)sender; string strBtnID = btn.ID; string strAlert; buyAppModel.ClassNumber = NumbersTBX.Text.Trim();//分类号码 buyAppModel.Name = NameTBX.Text.Trim();//编号名称 if (NumbersTBX.Text.Trim() != "") { int iNum; if (int.TryParse(NumTBX.Text.Trim(), out iNum)) { buyAppModel.Numbers = iNum.ToString();//购买数量 } else { LabMS.Common.JShelper.JSAlert(Page, "err", "购买数量只能为不小于0整数!"); return; } } buyAppModel.Type = TypeDDL.SelectedValue;//类型 if (strBtnID == "ModifyBtn") { buyAppModel.State = "0";//状态 strAlert = "修改成功!"; } else { buyAppModel.State = "1";//状态 buyAppModel.AppTime = DateTime.Now;//申请时间 strAlert = "申请成功!"; } buyAppModel.AppComment = LabMS.Common.codehelper.Encode(AppCommentTBX.Text.Trim());//申请备注 int ID; if (int.TryParse(IDHF.Value, out ID)) { buyAppModel.ID = ID; } else { LabMS.Common.JShelper.JSAlert(Page, "err", "参数不合法,请重新打开修改页面!"); return; } try { buyAppBLL.Update(buyAppModel); LabMS.Common.JShelper.JSAlertAndRedirect(Page, "success", strAlert, "buyappperview.aspx?ID=" + ID); } catch { LabMS.Common.JShelper.JSAlert(Page, "err", "操作失败!"); } }