/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.SuppliesRecipients GetModel(long ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,EncodedWarehouse,Numbers,Name,Words,Arrow,QuantityRecipients,Recipients,Laboratory,EncodedTime,UnitPrice,TotalAmount,Comment,Operator,OperatDate from SuppliesRecipients "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt)}; parameters[0].Value = ID; LabMS.Model.SuppliesRecipients model=new LabMS.Model.SuppliesRecipients(); 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.EncodedWarehouse=ds.Tables[0].Rows[0]["EncodedWarehouse"].ToString(); model.Numbers=ds.Tables[0].Rows[0]["Numbers"].ToString(); model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); model.Words=ds.Tables[0].Rows[0]["Words"].ToString(); model.Arrow=ds.Tables[0].Rows[0]["Arrow"].ToString(); model.QuantityRecipients=ds.Tables[0].Rows[0]["QuantityRecipients"].ToString(); model.Recipients=ds.Tables[0].Rows[0]["Recipients"].ToString(); model.Laboratory=ds.Tables[0].Rows[0]["Laboratory"].ToString(); if(ds.Tables[0].Rows[0]["EncodedTime"].ToString()!="") { model.EncodedTime=DateTime.Parse(ds.Tables[0].Rows[0]["EncodedTime"].ToString()); } model.UnitPrice=ds.Tables[0].Rows[0]["UnitPrice"].ToString(); model.TotalAmount=ds.Tables[0].Rows[0]["TotalAmount"].ToString(); model.Comment=ds.Tables[0].Rows[0]["Comment"].ToString(); model.Operator=ds.Tables[0].Rows[0]["Operator"].ToString(); if(ds.Tables[0].Rows[0]["OperatDate"].ToString()!="") { model.OperatDate=DateTime.Parse(ds.Tables[0].Rows[0]["OperatDate"].ToString()); } return model; } else { return null; } }
protected void Submit_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrEmpty(tbCNub.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "耗材编号不能为空!"); return; } if (string.IsNullOrEmpty(tbUserNub.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "领用数量不能为空!"); return; } string strTotalNub = lbAllNub.Text.Trim(); decimal iTotalNub = 0; decimal.TryParse(strTotalNub, out iTotalNub); string strUseNub = tbUserNub.Text.Trim(); decimal iUserNub = 0; decimal.TryParse(strUseNub, out iUserNub); if (iUserNub > iTotalNub) { LabMS.Common.JShelper.JSAlert(Page, "err", "库存不足!"); return; } if (string.IsNullOrEmpty(tbRPersion.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "领用人不能为空!"); return; } if (string.IsNullOrEmpty(tbLabName.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "领用实验室不能为空!"); return; } if (string.IsNullOrEmpty(tbRecipientsDate.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "领用时间不能为空!"); return; } #endregion ExtendBLL.SuppliesRecipients EbSRecipient = new ExtendBLL.SuppliesRecipients(); LabMS.Model.SuppliesRecipients mSRecipient = new LabMS.Model.SuppliesRecipients(); mSRecipient.Comment = tbRemarks.Text.Trim(); mSRecipient.Arrow = ddlArrow.SelectedValue; mSRecipient.UnitPrice = "0"; if (tbUintPrice.Value.Trim().Equals("")) { mSRecipient.UnitPrice = "0"; } else { mSRecipient.UnitPrice = tbUintPrice.Value.Trim(); } DateTime tempTime = new DateTime(); if (DateTime.TryParse(tbRecipientsDate.Text.Trim(), out tempTime)) { mSRecipient.EncodedTime = tempTime; } mSRecipient.EncodedWarehouse = tbLocationCode.Text; mSRecipient.Laboratory = tbLabCode.Value.Trim(); mSRecipient.Name = lbCName.Text; mSRecipient.Numbers = tbCNub.Text.Trim(); mSRecipient.OperatDate = DateTime.Now; mSRecipient.Operator = ""; decimal iTemp1 = 0; decimal iTemp2 = 0; if (decimal.TryParse(tbUserNub.Text.Trim(), out iTemp1)) { mSRecipient.QuantityRecipients = iTemp1.ToString(); if (decimal.TryParse(mSRecipient.UnitPrice.Trim(), out iTemp2)) { iTemp1 *= iTemp2; mSRecipient.TotalAmount = iTemp1.ToString(); } else { mSRecipient.TotalAmount = "0"; } } mSRecipient.Recipients = tbRPersionCode.Value.Trim(); mSRecipient.Words = lbTypeNub.Text.Trim(); try { EbSRecipient.ExtendAdd(mSRecipient, iTotalNub); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message.ToString(); return; } LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "领用成功!", "consumsrecipients.aspx"); }
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); } }