protected void lbSave_Click(object sender, EventArgs e)
        {
            lbErr.Visible = false;
            Model.InstrumentAndConsumables instrument = new LabMS.Model.InstrumentAndConsumables();
            BLL.InstrumentAndConsumables binstrument = new LabMS.BLL.InstrumentAndConsumables();
            instrument.ID = Convert.ToInt64(strID);
            instrument.Arrow = ddlArrow.SelectedValue;
            instrument.ClassNumber = ddlCClass.SelectedValue;
            instrument.ClassNumber = tbKindNum.Text.Trim();
            instrument.CountryCode = tbCountry.Text;
            instrument.CreatedDate = DateTime.Today;
            instrument.Documents = tbDocuments.Text.Trim();
            instrument.FactoryCode = tbFactoryCode.Text.Trim();
            instrument.FundsSubject = ddlFundsSubject.SelectedValue;
            instrument.Measurement = ddlModle.SelectedValue;
            instrument.Model = tbModel.Text.Trim();
            instrument.Name = tbInstrumentName.Text.Trim();
            instrument.Numbers = tbInstrumentNum.Text.Trim();
            instrument.OperatorDate = DateTime.Now;
            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(tbProductionDate.Text.Trim(), out tempTime))
            {
                instrument.ProductionDate = tempTime;
            }
            if (DateTime.TryParse(tbPurchaseDate.Text.Trim(), out tempTime))
            {
                instrument.PurchaseDate = tempTime;
            }
            decimal iTemp = 0;
            if (decimal.TryParse(tbAmount.Text.Trim(), out iTemp))
            {
                instrument.Quantity = iTemp;
            }
            instrument.Source = ddlSource.SelectedValue;
            instrument.StockLocation = tbLocationCode.Text;
            instrument.PresentSituation = ddlPresentSituation.SelectedValue;
            instrument.Type = "lowvalue";
            instrument.ContactPhone = tbContactPhone.Text;
            instrument.ResponesoblePerson = tbResponesoblePerson.Text;
            instrument.UnitPrice = tbUnitPrice.Text.Trim();
            instrument.Purpose = tbPurpose.Text;
            instrument.Standards = tbStandards.Text;
            //修改图片
            try
            {
                if (imageUpload.HasFile)
                {
                    HttpPostedFile upPhoto = imageUpload.PostedFile;
                    int upPhotoLength = upPhoto.ContentLength;
                    string PhotoContentType = upPhoto.ContentType;
                    byte[] PhotoArray = new byte[upPhotoLength];
                    Stream PhotoStream = upPhoto.InputStream;
                    PhotoStream.Read(PhotoArray, 0, upPhotoLength);

                    instrument.Pic = PhotoArray;//相片
                    instrument.PicType = PhotoContentType;//图片类型
                }
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "Picwrong", "程序错误:图片保存出错");
            }
            //无供应商
            try
            {
                binstrument.Update(instrument);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "修改成功!", "lowvalueedit.aspx?ID=" + strID);
            }
            catch (Exception ex)
            {
                lbErr.Visible = true;
                lbErr.Text = ex.Message.ToString();
            }
        }
Exemple #2
0
        private void savedata(string status)
        {
            BLL.GoodsMaintain bgoodsmaintain = new LabMS.BLL.GoodsMaintain();
            Model.GoodsMaintain goodsmaintain = bgoodsmaintain.GetModel(Convert.ToInt32(strID.Text));
            goodsmaintain.MCo = tbRepairGroup.Text;
            goodsmaintain.MLinkman = tbTransfer.Text.Trim();
            goodsmaintain.MPhone = tbPhoneNum.Text;
            goodsmaintain.MComment = tbComments.Text;
            if (!tbRepairTime.Text.Trim().Equals(""))
            {
                goodsmaintain.MDate = DateTime.Parse(tbRepairTime.Text);
            }
            goodsmaintain.LabName = ddlLab.SelectedValue;
            goodsmaintain.AssetManagers = tbManager.Text;
            goodsmaintain.Tel = tbTelNum.Text;
            goodsmaintain.Guarantee = tbIsInTime.SelectedValue;
            goodsmaintain.Applicant = tbApplyer.Text.Trim();
            goodsmaintain.Describe = tbDescription.Text;
            goodsmaintain.Status = status;
            goodsmaintain.AcceptanceViews = tbAcceptanceViews.Text;

            BLL.InstrumentAndConsumables biac = new LabMS.BLL.InstrumentAndConsumables();
            Model.InstrumentAndConsumables iac;
            if (biac.GetModelList(" Numbers=" + tbinstrumentNum.Text.Trim()).Count != 0)
            {
                iac = biac.GetModelList(" Numbers=" + tbinstrumentNum.Text.Trim())[0];
                try
                {
                    bgoodsmaintain.Update(goodsmaintain);
                }
                catch (Exception e)
                {
                    Common.JShelper.JSAlert(Page, "Err", status + "失败");
                    return;
                }
                iac.Status = status;
                if (status == "正常")
                {
                    int i = Convert.ToInt32(iac.Quantity);
                    i++;
                    iac.Quantity = i;
                }
                biac.Update(iac);
                Common.JShelper.JSAlertAndRedirect(Page, "Err", status + "成功", "lowconformlist.aspx");
            }
            else
            {
                Common.JShelper.JSAlert(Page, "Err", status + "失败");
                return;
            }
        }
 protected void savedata(string status)
 {
     if (tbInstrumentName.Text.Trim() == "")
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "仪器不可以为空!");
         return;
     }
     if (tbApplyer.Text.Trim() == "")
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "申请人不可以为空!");
         return;
     }
     BLL.GoodsMaintain binstrument = new LabMS.BLL.GoodsMaintain();
     Model.GoodsMaintain instrment = new LabMS.Model.GoodsMaintain();
     instrment.Numbers = tbInstrumentNum.Text;
     instrment.Name = tbInstrumentName.Text;
     instrment.AssetManagers = tbManager.Text.Trim();
     instrment.Tel = tbTelNum.Text;
     instrment.StorageSites = tbLocation.Text; //ddlStockLocation.SelectedValue;
     instrment.LabName = ddlLab.SelectedValue;
     instrment.Guarantee = isInTime.SelectedValue;
     instrment.Applicant = tbApplyer.Text.Trim();
     instrment.ReportedTime = DateTime.Parse( tbReportTime.Text);
     instrment.Describe = tbDescription.Text;
     instrment.Status = status.ToString().Trim();
     BLL.InstrumentAndConsumables bins = new LabMS.BLL.InstrumentAndConsumables();
     Model.InstrumentAndConsumables ins = (bins.GetModelList(" Numbers="+tbInstrumentNum.Text.Trim()))[0];
     ins.PresentSituation = status;
     int i = Convert.ToInt32(ins.Quantity);
     i--;
     ins.Quantity = i;
     try
     {
         bins.Update(ins);
     }
     catch (Exception e)
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "添加失败1");
         return;
     }
     try
     {
         binstrument.Add(instrment);
     }
     catch (Exception ee)
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "添加失败2"+ee.Message);
         return;
     }
     LabMS.Common.JShelper.JSAlertAndRedirect(Page, "err", "添加成功", "lowdamagereport.aspx");
 }