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; }
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 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", "操作失败!"); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.BuyApp GetModel(long ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,ClassNumber,Numbers,Name,Type,AppPerson,AppTime,AppNub,State,AppComment,VerifyPerson,VerifyTime,VerifyComment from BuyApp "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt)}; parameters[0].Value = ID; LabMS.Model.BuyApp model=new LabMS.Model.BuyApp(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.ClassNumber=ds.Tables[0].Rows[0]["ClassNumber"].ToString(); model.Numbers=ds.Tables[0].Rows[0]["Numbers"].ToString(); model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); model.Type=ds.Tables[0].Rows[0]["Type"].ToString(); model.AppPerson=ds.Tables[0].Rows[0]["AppPerson"].ToString(); if(ds.Tables[0].Rows[0]["AppTime"].ToString()!="") { model.AppTime=DateTime.Parse(ds.Tables[0].Rows[0]["AppTime"].ToString()); } model.AppNub=ds.Tables[0].Rows[0]["AppNub"].ToString(); model.State=ds.Tables[0].Rows[0]["State"].ToString(); model.AppComment=ds.Tables[0].Rows[0]["AppComment"].ToString(); model.VerifyPerson=ds.Tables[0].Rows[0]["VerifyPerson"].ToString(); if(ds.Tables[0].Rows[0]["VerifyTime"].ToString()!="") { model.VerifyTime=DateTime.Parse(ds.Tables[0].Rows[0]["VerifyTime"].ToString()); } model.VerifyComment=ds.Tables[0].Rows[0]["VerifyComment"].ToString(); return model; } else { return null; } }