예제 #1
0
        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);
            }
        }
        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(tbLabName.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "领用实验室不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbRecipientsDate.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "领用时间不能为空!");
                return;
            }

            #endregion
            lbErr.Visible = false;
            Button btn = (Button)sender;
            string strbtnName = btn.ID;
            LabMS.BLL.RecipientsApp brecipientsApp = new LabMS.BLL.RecipientsApp();
            LabMS.Model.RecipientsApp recipientsApp = new LabMS.Model.RecipientsApp();
            recipientsApp.State = "0";
            if (strbtnName == "Submit")
            {
                recipientsApp.State = "1";
                recipientsApp.AppTime = DateTime.Now;
            }
            recipientsApp.AppComment = Common.codehelper.Encode(Comment.Text.Trim());
            recipientsApp.AppNub = tbUserNub.Text.Trim();
            recipientsApp.Arrow = ddlArrow.SelectedValue;
            recipientsApp.ClassNumber = tbCNub.Text;
            recipientsApp.EncodedWarehouse = ddlLabs.SelectedValue;
            recipientsApp.Laboratory = tbLabCode.Value;
            recipientsApp.MRecipients = UserRealName;
            recipientsApp.Name = lbCName.Text;
            recipientsApp.Numbers = "";//编号不需要
            DateTime temp = new DateTime();
            if (DateTime.TryParse(tbRecipientsDate.Text, out temp))
            {
                recipientsApp.RecipientTime = temp;
            }
            else
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "领用时间格式错误!");
                return;
            }
            recipientsApp.Type = ddlEType.SelectedValue;
            recipientsApp.Words = lbTypeNub.Text;
            try
            {
                brecipientsApp.Add(recipientsApp);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "操作成功!", "recipientsapplication.aspx");
            }
            catch (Exception ex)
            {
                lbErr.Text = ex.Message;
                lbErr.Visible = true;
            }
        }
예제 #3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.RecipientsApp GetModel(long ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,ClassNumber,Numbers,Name,Type,MRecipients,AppTime,RecipientTime,AppNub,State,AppComment,VerifyPerson,VerifyTime,VerifyComment,EncodedWarehouse,Words,Arrow,Laboratory from RecipientsApp ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.BigInt)};
            parameters[0].Value = ID;

            LabMS.Model.RecipientsApp model=new LabMS.Model.RecipientsApp();
            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.MRecipients=ds.Tables[0].Rows[0]["MRecipients"].ToString();
                if(ds.Tables[0].Rows[0]["AppTime"].ToString()!="")
                {
                    model.AppTime=DateTime.Parse(ds.Tables[0].Rows[0]["AppTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["RecipientTime"].ToString()!="")
                {
                    model.RecipientTime=DateTime.Parse(ds.Tables[0].Rows[0]["RecipientTime"].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();
                model.EncodedWarehouse=ds.Tables[0].Rows[0]["EncodedWarehouse"].ToString();
                model.Words=ds.Tables[0].Rows[0]["Words"].ToString();
                model.Arrow=ds.Tables[0].Rows[0]["Arrow"].ToString();
                model.Laboratory=ds.Tables[0].Rows[0]["Laboratory"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }