示例#1
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            Model.InstrumentAndConsumables instrument = new LabMS.Model.InstrumentAndConsumables();
            BLL.InstrumentAndConsumables binstrument = new LabMS.BLL.InstrumentAndConsumables();
            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;
            instrument.Standards = tbStandards.Text;
            instrument.ResponesoblePerson = tbResponesoblePerson.Text.Trim();
            instrument.ContactPhone = tbContactPhone.Text.Trim();
            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.PresentSituation = ddlPresentSituation.SelectedValue;
            instrument.Source = ddlSource.SelectedValue;
            instrument.SpaceLocation = tbLocationCode.Text;
            instrument.StockLocation = tbLocationCode.Text;
            instrument.Type = "lowvalue";
            instrument.Purpose = tbPurpose.Text;
            instrument.UnitPrice = tbUnitPrice.Text.Trim();
            instrument.Status = "正常";
            //上传图片
            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.Add(instrument);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "添加成功!", "addlowvalue.aspx");
            }
            catch (Exception ex)
            {
                lbErr.Visible = true;
                lbErr.Text = ex.Message.ToString();
            }
        }
示例#2
0
        protected void lbModify_Click(object sender, EventArgs e)
        {
            Model.InstrumentAndConsumables valuables = new LabMS.Model.InstrumentAndConsumables();
            BLL.InstrumentAndConsumables bvaluables = new LabMS.BLL.InstrumentAndConsumables();

            valuables = bvaluables.GetModel(long.Parse(LabID.Value));

            valuables.Numbers = tbInstrumentNum.Text.Trim();
            valuables.ClassNumber = tbKindNum.Text.Trim();
            valuables.Name = tbInstrumentName.Text.Trim();
            valuables.Standards = tbStandards.Text.Trim();
            valuables.Model = tbModel.Text.Trim();
            valuables.CountryCode = tbCountryCode.Text.Trim();
            valuables.StockLocation = tbLocationCode.Text;
            valuables.SpaceLocation = tbLocationCode.Text;
            valuables.Quantity = Convert.ToInt32(tbAmount.Text);
            valuables.UnitPrice = tbUnitPrice.Text.Trim();
            valuables.FactoryCode = tbFactoryCode.Text.Trim();
            valuables.Documents = tbDocuments.Text.Trim();
            valuables.Measurement = tbMeasurement.Text.Trim();
            valuables.Source = ddlSource.SelectedValue;

            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(tbProductionDate.Text.Trim(), out tempTime))
            {
                valuables.ProductionDate = tempTime;
            }
            if (DateTime.TryParse(tbPurchaseDate.Text.Trim(), out tempTime))
            {
                valuables.PurchaseDate = tempTime;
            }
            if (DateTime.TryParse(tbOpeningTime.Text.Trim(), out tempTime))
            {
                valuables.OpeningTime = tempTime;
            }

            valuables.CreatedDate = Convert.ToDateTime(tbCreatedDate.Text);
            valuables.Arrow = ddlArrow.SelectedValue;
            valuables.PresentSituation = ddlPresentSituation.SelectedValue;
            valuables.FundsSubject = ddlFundsSubject.SelectedValue;
            valuables.ResponesoblePerson = tbResponesoblePerson.Text.Trim();
            valuables.ContactPhone = tbContactPhone.Text.Trim();
            valuables.Charges = tbCharges.Text.Trim();
            valuables.ZipCode = tbZipCode.Text.Trim();
            valuables.MailingAddress = tbMailingAddress.Text.Trim();
            valuables.Purpose = tbPurpose.Text.Trim();
            valuables.OperatorDate = DateTime.Now;
            valuables.Type = "guizhongyiqi";
            //修改图片
            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);

                    valuables.Pic = PhotoArray;//相片
                    valuables.PicType = PhotoContentType;//图片类型
                }
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "Picwrong", "程序错误:图片保存出错");
            }
            try
            {
                bvaluables.Update(valuables);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "ModifySuccess", "修改成功!", "valuablesedit.aspx?ID=" + LabID.Value);
            }
            catch (Exception ex)
            {
                Err.Text = ex.Message.ToString();
            }
        }
示例#3
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(tbCNub.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "耗材编号不能为空!");
                return;
            }
            ExtendBLL.InstrumentAndConsumables extendconsum
                = new ExtendBLL.InstrumentAndConsumables();
            bool bLegal =  extendconsum.isNumbersLegal(tbCNub.Text.Trim(), "xiaohaopin");
            if (!bLegal)
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "耗材编号已存在!");
                return;
            }
            if (string.IsNullOrEmpty(tbCName.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "耗材名称不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbTypeNub.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "型号不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbNub.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "数量不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbPrice.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "单价不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbBuyDate.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "购置日期不能为空!");
                return;
            }

            #endregion

            lbErr.Visible = false;
            Model.InstrumentAndConsumables consumables = new LabMS.Model.InstrumentAndConsumables();
            BLL.InstrumentAndConsumables bconsumables = new LabMS.BLL.InstrumentAndConsumables();
            consumables.Arrow = ddlArrow.SelectedValue;
            consumables.ClassNumber = ddlCClass.SelectedValue;
            consumables.Name = tbClassNub.Text.Trim();
            consumables.CountryCode = tbCountry.Text;
            consumables.CreatedDate = DateTime.Today;
            consumables.Documents = tbDocuments.Text.Trim();
            consumables.FactoryCode = tbFNub.Text.Trim();
            consumables.FundsSubject = ddlFundsSubject.SelectedValue;
            consumables.Measurement = ddlModle.SelectedValue;
            consumables.Model = tbTypeNub.Text.Trim();
            consumables.Name = tbCName.Text.Trim();
            consumables.Numbers = tbCNub.Text.Trim();
            consumables.OperatorDate = DateTime.Now;
            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(tbProduceDate.Text.Trim(), out tempTime))
            {
                consumables.ProductionDate = tempTime;
            }
            if (DateTime.TryParse(tbBuyDate.Text.Trim(), out tempTime))
            {
                consumables.PurchaseDate = tempTime;
            }
            decimal iTemp = 0;
            if (decimal.TryParse(tbNub.Text.Trim(), out iTemp))
            {
                consumables.Quantity = iTemp;
            }
            consumables.Source = ddlComeFrom.SelectedValue;
            consumables.SpaceLocation = tbLocationCode.Text;
            consumables.StockLocation = tbLocationCode.Text; ;
            consumables.Type = "xiaohaopin";
            consumables.UnitPrice = tbPrice.Text.Trim();
            consumables.Purpose = tbPurpose.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);

                    consumables.Pic = PhotoArray;//相片
                    consumables.PicType = PhotoContentType;//图片类型
                }
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "Picwrong", "程序错误:图片保存出错");
            }
            //无供应商
            try
            {
                bconsumables.Add(consumables);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "添加成功!", "addconsum.aspx");
            }
            catch (Exception ex)
            {
                lbErr.Visible = true;
                lbErr.Text = ex.Message.ToString();
            }
        }
 /// <summary>
 /// ��������б�
 /// </summary>
 public List<LabMS.Model.InstrumentAndConsumables> GetModelList(string strWhere)
 {
     DataSet ds = dal.GetList(strWhere);
     List<LabMS.Model.InstrumentAndConsumables> modelList = new List<LabMS.Model.InstrumentAndConsumables>();
     int rowsCount = ds.Tables[0].Rows.Count;
     if (rowsCount > 0)
     {
         LabMS.Model.InstrumentAndConsumables model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new LabMS.Model.InstrumentAndConsumables();
             model.ID = long.Parse(ds.Tables[0].Rows[n]["ID"].ToString());
             model.Numbers = ds.Tables[0].Rows[n]["Numbers"].ToString();
             model.Type = ds.Tables[0].Rows[n]["Type"].ToString();
             model.ClassNumber = ds.Tables[0].Rows[n]["ClassNumber"].ToString();
             model.Name = ds.Tables[0].Rows[n]["Name"].ToString();
             model.Standards = ds.Tables[0].Rows[n]["Standards"].ToString();
             model.Model = ds.Tables[0].Rows[n]["Model"].ToString();
             model.CountryCode = ds.Tables[0].Rows[n]["CountryCode"].ToString();
             model.StockLocation = ds.Tables[0].Rows[n]["StockLocation"].ToString();
             model.SpaceLocation = ds.Tables[0].Rows[n]["SpaceLocation"].ToString();
             if (ds.Tables[0].Rows[n]["Quantity"].ToString() != "")
             {
                 model.Quantity = decimal.Parse(ds.Tables[0].Rows[n]["Quantity"].ToString());
             }
             model.FactoryCode = ds.Tables[0].Rows[n]["FactoryCode"].ToString();
             model.UnitPrice = ds.Tables[0].Rows[n]["UnitPrice"].ToString();
             model.Documents = ds.Tables[0].Rows[n]["Documents"].ToString();
             model.Measurement = ds.Tables[0].Rows[n]["Measurement"].ToString();
             model.Source = ds.Tables[0].Rows[n]["Source"].ToString();
             if (ds.Tables[0].Rows[n]["PurchaseDate"].ToString() != "")
             {
                 model.PurchaseDate = DateTime.Parse(ds.Tables[0].Rows[n]["PurchaseDate"].ToString());
             }
             if (ds.Tables[0].Rows[n]["ProductionDate"].ToString() != "")
             {
                 model.ProductionDate = DateTime.Parse(ds.Tables[0].Rows[n]["ProductionDate"].ToString());
             }
             model.Arrow = ds.Tables[0].Rows[n]["Arrow"].ToString();
             if (ds.Tables[0].Rows[n]["CreatedDate"].ToString() != "")
             {
                 model.CreatedDate = DateTime.Parse(ds.Tables[0].Rows[n]["CreatedDate"].ToString());
             }
             model.FundsSubject = ds.Tables[0].Rows[n]["FundsSubject"].ToString();
             model.Status = ds.Tables[0].Rows[n]["Status"].ToString();
             model.ResponesoblePerson = ds.Tables[0].Rows[n]["ResponesoblePerson"].ToString();
             model.ContactPhone = ds.Tables[0].Rows[n]["ContactPhone"].ToString();
             model.Purpose = ds.Tables[0].Rows[n]["Purpose"].ToString();
             if (ds.Tables[0].Rows[n]["OpeningTime"].ToString() != "")
             {
                 model.OpeningTime = DateTime.Parse(ds.Tables[0].Rows[n]["OpeningTime"].ToString());
             }
             model.Charges = ds.Tables[0].Rows[n]["Charges"].ToString();
             model.ZipCode = ds.Tables[0].Rows[n]["ZipCode"].ToString();
             model.MailingAddress = ds.Tables[0].Rows[n]["MailingAddress"].ToString();
             model.PresentSituation = ds.Tables[0].Rows[n]["PresentSituation"].ToString();
             model.Operator = ds.Tables[0].Rows[n]["Operator"].ToString();
             if (ds.Tables[0].Rows[n]["OperatorDate"].ToString() != "")
             {
                 model.OperatorDate = DateTime.Parse(ds.Tables[0].Rows[n]["OperatorDate"].ToString());
             }
             if (ds.Tables[0].Rows[n]["Pic"].ToString() != "")
             {
                 model.Pic = (byte[])ds.Tables[0].Rows[n]["Pic"];
             }
             model.PicType = ds.Tables[0].Rows[n]["PicType"].ToString();
             modelList.Add(model);
         }
     }
     return modelList;
 }