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);
            }
        }