protected void Page_Load(object sender, EventArgs e) { Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); Response.Expires = 0; Response.CacheControl = "no-cache"; if (Request.QueryString["ID"] != null) { int EquipID = int.Parse(Request.QueryString["ID"]); LabMS.BLL.InstrumentAndConsumables equip = new LabMS.BLL.InstrumentAndConsumables(); LabMS.Model.InstrumentAndConsumables equipinfo = new LabMS.Model.InstrumentAndConsumables(); equipinfo = equip.GetModel(EquipID); byte[] PhotoArray = equipinfo.Pic; string PhotoType = equipinfo.PicType; if (PhotoArray != null) { if (PhotoArray.Length != 0) { Response.ContentType = PhotoType; Response.BinaryWrite(PhotoArray); Response.End(); } } } }
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(); } }
protected void lbSave_Click(object sender, EventArgs e) { Model.InstrumentAndConsumables valuables = new LabMS.Model.InstrumentAndConsumables(); BLL.InstrumentAndConsumables bvaluables = new LabMS.BLL.InstrumentAndConsumables(); 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.Add(valuables); LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "添加成功!", "addvaluables.aspx"); } catch (Exception ex) { Err.Text = ex.Message.ToString(); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.InstrumentAndConsumables GetModel(long ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,Numbers,Type,ClassNumber,Name,Standards,Model,CountryCode,StockLocation,SpaceLocation,Quantity,FactoryCode,UnitPrice,Documents,Measurement,Source,PurchaseDate,ProductionDate,Arrow,CreatedDate,FundsSubject,Status,ResponesoblePerson,ContactPhone,Purpose,OpeningTime,Charges,ZipCode,MailingAddress,PresentSituation,Operator,OperatorDate,Pic,PicType from InstrumentAndConsumables "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt)}; parameters[0].Value = ID; LabMS.Model.InstrumentAndConsumables model=new LabMS.Model.InstrumentAndConsumables(); 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.Numbers=ds.Tables[0].Rows[0]["Numbers"].ToString(); model.Type=ds.Tables[0].Rows[0]["Type"].ToString(); model.ClassNumber=ds.Tables[0].Rows[0]["ClassNumber"].ToString(); model.Name=ds.Tables[0].Rows[0]["Name"].ToString(); model.Standards=ds.Tables[0].Rows[0]["Standards"].ToString(); model.Model=ds.Tables[0].Rows[0]["Model"].ToString(); model.CountryCode=ds.Tables[0].Rows[0]["CountryCode"].ToString(); model.StockLocation=ds.Tables[0].Rows[0]["StockLocation"].ToString(); model.SpaceLocation=ds.Tables[0].Rows[0]["SpaceLocation"].ToString(); if(ds.Tables[0].Rows[0]["Quantity"].ToString()!="") { model.Quantity=decimal.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString()); } model.FactoryCode=ds.Tables[0].Rows[0]["FactoryCode"].ToString(); model.UnitPrice=ds.Tables[0].Rows[0]["UnitPrice"].ToString(); model.Documents=ds.Tables[0].Rows[0]["Documents"].ToString(); model.Measurement=ds.Tables[0].Rows[0]["Measurement"].ToString(); model.Source=ds.Tables[0].Rows[0]["Source"].ToString(); if(ds.Tables[0].Rows[0]["PurchaseDate"].ToString()!="") { model.PurchaseDate=DateTime.Parse(ds.Tables[0].Rows[0]["PurchaseDate"].ToString()); } if(ds.Tables[0].Rows[0]["ProductionDate"].ToString()!="") { model.ProductionDate=DateTime.Parse(ds.Tables[0].Rows[0]["ProductionDate"].ToString()); } model.Arrow=ds.Tables[0].Rows[0]["Arrow"].ToString(); if(ds.Tables[0].Rows[0]["CreatedDate"].ToString()!="") { model.CreatedDate=DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString()); } model.FundsSubject=ds.Tables[0].Rows[0]["FundsSubject"].ToString(); model.Status=ds.Tables[0].Rows[0]["Status"].ToString(); model.ResponesoblePerson=ds.Tables[0].Rows[0]["ResponesoblePerson"].ToString(); model.ContactPhone=ds.Tables[0].Rows[0]["ContactPhone"].ToString(); model.Purpose=ds.Tables[0].Rows[0]["Purpose"].ToString(); if(ds.Tables[0].Rows[0]["OpeningTime"].ToString()!="") { model.OpeningTime=DateTime.Parse(ds.Tables[0].Rows[0]["OpeningTime"].ToString()); } model.Charges=ds.Tables[0].Rows[0]["Charges"].ToString(); model.ZipCode=ds.Tables[0].Rows[0]["ZipCode"].ToString(); model.MailingAddress=ds.Tables[0].Rows[0]["MailingAddress"].ToString(); model.PresentSituation=ds.Tables[0].Rows[0]["PresentSituation"].ToString(); model.Operator=ds.Tables[0].Rows[0]["Operator"].ToString(); if(ds.Tables[0].Rows[0]["OperatorDate"].ToString()!="") { model.OperatorDate=DateTime.Parse(ds.Tables[0].Rows[0]["OperatorDate"].ToString()); } if (ds.Tables[0].Rows[0]["Pic"].ToString() != "") { model.Pic = (byte[])ds.Tables[0].Rows[0]["Pic"]; } model.PicType = ds.Tables[0].Rows[0]["PicType"].ToString(); return model; } else { return null; } }