public void bind(string strWhere) { lbErr.Visible = false; List<Model.RecipientsApp> listrescipientsappmodule = new List<Model.RecipientsApp>(); ExtendBLL.RecipientsApp berescipients = new ExtendBLL.RecipientsApp(); listrescipientsappmodule = berescipients.GetModelList(strWhere); LabMS.BLL.Lab blab = new LabMS.BLL.Lab(); List<LabMS.Model.Lab> mLab = new List<LabMS.Model.Lab>(); try { foreach (Model.RecipientsApp rapp in listrescipientsappmodule) { mLab = blab.GetModelList("Lab_Code = '" + rapp.EncodedWarehouse + "'"); if (mLab.Count > 0) { rapp.EncodedWarehouse = mLab[0].Lab_Name; } else { rapp.EncodedWarehouse = "无"; } mLab = blab.GetModelList("Lab_Code = '" + rapp.Laboratory + "'"); if (mLab.Count > 0) { rapp.Laboratory = mLab[0].Lab_Name; } else { rapp.Laboratory = "无"; } rapp.Type = LabMS.Common.Global.GetEquipmentByCode(rapp.Type); rapp.State = LabMS.Common.Status.GetOpenProjectStatus(rapp.State); } } catch(Exception ex) { lbErr.Text = ex.Message; lbErr.Visible = true; return; } GridViewrapp.DataSource = listrescipientsappmodule; GridViewrapp.DataBind(); }
protected void btnApp_Click(object sender, EventArgs e) { lbErr.Visible = false; Button btn = (Button)sender; string strAudit = ""; string strAlert = ""; if (btn.ID == "btnCancelApp") { strAudit = "0"; strAlert = "撤销申请成功!"; } if (btn.ID == "btnApp") { strAudit = "1"; strAlert = "申请成功,请等待审核!"; } if (btn.ID == "tbnCheck") { strAudit = "3"; strAlert = "审核成功!"; LabMS.BLL.RecipientsApp brapp = new LabMS.BLL.RecipientsApp(); LabMS.Model.RecipientsApp mrecipeintsapp = new LabMS.Model.RecipientsApp(); try { mrecipeintsapp = brapp.GetModel(long.Parse(tbID.Text)); } catch (Exception ex) { lbErr.Text = ex.Message; lbErr.Visible = true; return; } if (mrecipeintsapp == null) { Common.JShelper.JSAlert(Page, "err","数据错误,请删除此条记录!"); return; } List<LabMS.Model.InstrumentAndConsumables> mconsum = new List<LabMS.Model.InstrumentAndConsumables>(); LabMS.BLL.InstrumentAndConsumables bconsum = new LabMS.BLL.InstrumentAndConsumables(); mconsum = bconsum.GetModelList("Numbers='" + mrecipeintsapp.ClassNumber + "'"); if (mconsum.Count == 0) { Common.JShelper.JSAlert(Page, "err", "数据错误,请删除此条记录!"); return; } decimal iQuantityRecipients = 0; decimal.TryParse(mrecipeintsapp.AppNub, out iQuantityRecipients); if (iQuantityRecipients > mconsum[0].Quantity) { Common.JShelper.JSAlert(Page, "err", "库存不足!"); return; } else { if (mrecipeintsapp.Type == "xiaohaopin") { LabMS.Model.SuppliesRecipients model = new LabMS.Model.SuppliesRecipients(); model.Arrow = mrecipeintsapp.Arrow; model.Comment = "通过申请借出!"; model.EncodedTime = mrecipeintsapp.RecipientTime; model.EncodedWarehouse = mrecipeintsapp.EncodedWarehouse; model.Laboratory = mrecipeintsapp.Laboratory; model.Name = mrecipeintsapp.Name; model.Numbers = mrecipeintsapp.ClassNumber; model.OperatDate = DateTime.Today; model.Operator = "sys";//用户 model.QuantityRecipients = mrecipeintsapp.AppNub; model.Recipients = mrecipeintsapp.MRecipients; model.Words = mrecipeintsapp.Words; ExtendBLL.SuppliesRecipients EbSRecipient = new ExtendBLL.SuppliesRecipients(); try { EbSRecipient.ExtendAdd(model, (decimal)mconsum[0].Quantity); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message.ToString(); return; } } else { ExtendBLL.Recipients brecipients = new ExtendBLL.Recipients(); Model.Recipients recipients = new LabMS.Model.Recipients(); recipients.BorrowedState = "良好"; recipients.Comment = "通过申请借出!"; recipients.EncodedTime = mrecipeintsapp.RecipientTime; recipients.MRecipients = mrecipeintsapp.MRecipients; recipients.Name = mrecipeintsapp.Name; recipients.Numbers = mrecipeintsapp.ClassNumber; recipients.OperatDate = DateTime.Today; recipients.Operator = ""; recipients.Type = mrecipeintsapp.Type; try { brecipients.ExtendAdd(recipients); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message.ToString(); return; } } } } if (btn.ID == "tbnUnChek") { strAudit = "2"; strAlert = "审核成功!"; } ExtendBLL.RecipientsApp extendrapp = new ExtendBLL.RecipientsApp(); string strID = tbID.Text; try { if (btn.ID == "btnApp" || btn.ID == "btnCancelApp") { extendrapp.UpdateStatus(strAudit, strID); } else { string strChecker = UserRealName;//用户名 string strCheckContent = VerifyComment.Text.Trim(); extendrapp.SetCheck(strAudit, strID, DateTime.Today.ToShortDateString(), strChecker, strCheckContent); } } catch (Exception ex) { lbErr.Text = ex.Message; lbErr.Visible = true; return; } if (tbEType.Text != "") { Common.JShelper.JSAlertAndRedirect(Page, "success", strAlert, "recipientappperview.aspx?ID=" + tbID.Text + "&Type=" + tbEType.Text); } else { Common.JShelper.JSAlertAndRedirect(Page, "success", strAlert, "recipientappperview.aspx?ID=" + tbID.Text); } }