// 图片上传 protected void filePhoto_FileSelected(object sender, EventArgs e) { // 保存目录和键 string cate = Request.QueryString["cate"]; string key = Request.QueryString["key"]; // 准备目录 string folder = string.Format("~/Files/{0}/", cate); string folderPhysical = Server.MapPath(folder); if (!System.IO.Directory.Exists(folderPhysical)) { System.IO.Directory.CreateDirectory(folderPhysical); } // 上传图片并更新数据 if (filePhoto.HasFile) { // 文件名 string fileName = filePhoto.ShortFileName; fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = string.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMddHHmmssfffffff"), fileName); string physicalName = string.Format("{0}\\{1}", folderPhysical, fileName); string virtualName = string.Format("{0}/{1}", folder, fileName); // 上传新图片 filePhoto.SaveAs(physicalName); DrawHelper.CreateThumbnail(physicalName, physicalName, 500); // 数据库记录 Res.Add(key, virtualName); BindGrid(); } }
private void SetSingelPool(string key, object value) { if (!Res.ContainsKey(key)) { Res.Add(key, value); } else { Res[key] = value; } }
protected override void StringToOut(string result) { ResManMemEachYear buffer; buffer.Year = 0; buffer.Min = 0; buffer.Max = 0; buffer.Avg = 0; string ResOut = Code.Decoding(result); string buf = ""; int j = 0; for (int i = 0; i < ResOut.Length; i++) { if (ResOut[i] == ',') { if (j == 0) { buffer.Year = Int32.Parse(buf); j++; buf = ""; continue; } if (j == 1) { buffer.Min = Int32.Parse(buf); j++; buf = ""; continue; } if (j == 2) { buffer.Max = Int32.Parse(buf); j++; buf = ""; continue; } if (j == 3) { buffer.Avg = Int32.Parse(buf); j = 0; buf = ""; continue; } } if (ResOut[i] == ';') { Res.Add(buffer); continue; } buf += ResOut[i]; } }
protected override void Query() { using (var vc = new Videocards()) { var param = new SqlParameter("@Arch_Name", data.Arch); var result = vc.Database.SqlQuery <sql_Arch_cost_avg_Result>("sql_Arch_cost_avg @Arch_Name", param); ResArchCostAvg buf; foreach (var res in result) { buf.Name = res.Название; buf.Cost = res.Цена; Res.Add(buf); } } }
protected override void Query() { using (var vc = new Videocards()) { var mn = new SqlParameter("@Manufact_Name", data.ManName); var result = vc.Database.SqlQuery <sql_Manufact_memory_each_year_Result>("sql_Manufact_memory_each_year @Manufact_Name", mn); ResManMemEachYear buf; foreach (var res in result) { buf.Year = res.Год; buf.Min = res.Минимальный; buf.Max = res.Максимальный; buf.Avg = res.Средний; Res.Add(buf); } } }
protected override void Query() { using (var vc = new Videocards()) { var mn = new SqlParameter("@Manufact_name", data.ManName); var minE = new SqlParameter("@Min_Energy", data.MinEnerg); var maxE = new SqlParameter("@Max_Energy", data.MaxEnerg); var result = vc.Database.SqlQuery <sql_Manufact_energy_between_Result>("sql_Manufact_energy_between @Manufact_name, @Min_Energy, @Max_Energy", mn, minE, maxE); ResManEnergBeetw buf; foreach (var res in result) { buf.Name = res.Название; buf.Energy = res.Energy_use; Res.Add(buf); } } }
protected override void StringToOut(string result) { ResManEnergBeetwen buffer; buffer.Name = ""; buffer.Energy = 0; string ResOut = Code.Decoding(result); string buf = ""; int j = 0; for (int i = 0; i < ResOut.Length; i++) { if (ResOut[i] == ',') { if (j == 0) { buffer.Name = buf; j++; buf = ""; continue; } if (j == 1) { buffer.Energy = Int32.Parse(buf); j = 0; buf = ""; continue; } } if (ResOut[i] == ';') { Res.Add(buffer); continue; } buf += ResOut[i]; } }