/// <summary> /// 作品详情 /// </summary> /// <returns></returns> public ActionResult show(int id = 2) { WorksBLL wbll = new WorksBLL(); WorksModel list = wbll.idlist(id); return(View(list)); }
/// <summary> /// 用户收藏的作品 /// </summary> /// <returns></returns> public List <WorksModel> UserWorkShow(string id) { List <WorksModel> list = new List <WorksModel>(); string str = "select * from works a join dbo.UserInfo b on a.userid=b.userid where worksid in(" + id + ")"; SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand command = new SqlCommand(str, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { WorksModel a = new WorksModel(); a.Worksid = Convert.ToInt32(reader["Worksid"].ToString()); a.Worksname = reader["Worksname"].ToString(); a.Bra = reader["Bra"].ToString(); a.Size = Convert.ToInt32(reader["Size"].ToString()); a.thickness = reader["thickness"].ToString(); a.Worksdate = Convert.ToDateTime(reader["Worksdate"].ToString()); a.Worksstate = Convert.ToInt32(reader["Worksstate"].ToString()); a.Worksurl = reader["Worksurl"].ToString(); a.WorksCount = Convert.ToInt32(reader["WorksCount"].ToString()); a.Workcontent = reader["Workcontent"].ToString(); a.Username = reader["Username"].ToString(); list.Add(a); } con.Close(); return(list); }
// GET: Works/Edit/5 public ActionResult Edit(string id) { CreateSelect(); WorksModel model = WorksModel.GetWorksModelDetail(id); return(View(model)); }
/// <summary> ///作品表的显示 /// </summary> /// <returns></returns> public List <WorksModel> Workshow(int i) { string str = @"SELECT [Worksid] ,[Worksname] ,[Bra] ,[Size] ,[thickness] ,[Worksdate] ,[Worksstate] ,[Worksurl] ,[WorksCount] ,[Workcontent] ,[Userid] FROM [Venus].[dbo].[Works] order by "; if (i == 1) { str += " [Worksdate] "; } if (i == 2) { str += " [WorksCount] "; } if (i == 0) { str += " [Worksid] "; } str += "desc"; SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand command = new SqlCommand(str, con); List <WorksModel> list = new List <WorksModel>(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { WorksModel mm = new WorksModel(); mm.Worksid = Convert.ToInt32(reader["Worksid"].ToString()); mm.Worksname = reader["Worksname"].ToString(); mm.Bra = reader["Bra"].ToString(); mm.Size = Convert.ToInt32(reader["Size"].ToString()); mm.thickness = reader["thickness"].ToString(); mm.Worksdate = Convert.ToDateTime(reader["Worksdate"].ToString()); mm.Worksstate = Convert.ToInt32(reader["Worksstate"].ToString()); mm.Worksurl = reader["Worksurl"].ToString(); mm.WorksCount = Convert.ToInt32(reader["WorksCount"].ToString()); mm.Workcontent = reader["Workcontent"].ToString(); mm.Userid = Convert.ToInt32(reader["Userid"].ToString()); list.Add(mm); } con.Close(); return(list); }
/// <summary> /// 作品表的删除 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int WorksDelete(WorksModel mm) { string str = string.Format(@"DELETE FROM [dbo].[Works] WHERE Worksid='{0}'", mm.Worksid); SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand com = new SqlCommand(str, con); int i = com.ExecuteNonQuery(); con.Close(); return(i); }
public JsonResult Delete(string[] id) { for (int i = 0; i < id.Length; i++) { try { // TODO: Add delete logic here WorksModel.Delete(id[i]); } catch { //return View(); return(Json(id[i])); } } return(Json(id)); }
private void btnEdit_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } WorksModel model = (WorksModel)WorksBO.Instance.FindByPK(id); frmWorkView frm = new frmWorkView(); frm.Model = model; if (frm.ShowDialog() == DialogResult.OK) { loadGrid(); } }
public ActionResult Create(WorksModel collection, List <HttpPostedFileBase> Img) { // TODO: Add insert logic here collection.UploadWorksFiles = Img; if (string.IsNullOrEmpty(collection.Remarks)) { collection.Remarks = ""; } if (collection.Create()) { return(RedirectToAction("Index")); } CreateSelect(); return(View()); }
public async Task <IActionResult> Works(int id) { if (_signInManager.Context.User.Identity.IsAuthenticated) { if (HttpContext.User.IsInRole("Hr")) { await Initializer.InitialLayout("Work Places", ViewBag, _db, _signInManager, "Employee work places"); Employee employee = await _db.Employees .Where(e => e.Id == id) .FirstOrDefaultAsync(); List <OldWork> oldWorks = await _db.OldWorks .OrderBy(ow => ow.EnterTime) .Where(ow => ow.EmployeeId == id) .ToListAsync(); List <Work> works = await _db.Works .Where(w => w.EmployeeId == id) .OrderBy(w => w.EnterTime) .Include(w => w.BranchPosition) .ThenInclude(bp => bp.Branch) .ThenInclude(b => b.Company) .ThenInclude(c => c.Holding) .Include(w => w.BranchPosition) .ThenInclude(bp => bp.Position) .ThenInclude(p => p.Department) .ToListAsync(); WorksModel wm = new WorksModel { OldWorks = oldWorks, Works = works, Employee = employee }; return(View(wm)); } } return(RedirectToAction("Forbidden", "Error")); }
public ActionResult pictures(HttpPostedFileBase image) { if (image == null) { return(Content("<script>alert('请上传图片')</script>")); } var filname = Path.Combine(Request.MapPath("~/tupian"), Path.GetFileName(image.FileName)); WorksModel wmodel = new WorksModel(); wmodel.Worksname = Request["Worksname"].ToString(); wmodel.Bra = "A"; wmodel.Size = 32; wmodel.thickness = "薄款"; wmodel.Worksdate = DateTime.Now; wmodel.Worksstate = 1; wmodel.Worksurl = "/tupian/" + image.FileName; wmodel.WorksCount = 0; wmodel.Workcontent = Request["Workscontent"].ToString(); if (Session["userid"] == null) { return(Content("<script>alert('请登录');location.href='/Userinfo/index'</script>")); } else { wmodel.Userid = Convert.ToInt32(Session["userid"].ToString()); } if (bll.WorksADD(wmodel) > 0) { //上传到指定目录 image.SaveAs(filname); return(Content("<script>alert('上传成功');location.href='/Userhome/index'</script>")); } else { return(Content("<script>alert('上传失败')</script>")); } }
/// <summary> /// 根据作品id显示详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public WorksModel idlist(int id) { string str = @"SELECT [Worksid] ,[Worksname] ,[Bra] ,[Size] ,[thickness] ,[Worksdate] ,[Worksstate] ,[Worksurl] ,[WorksCount] ,[Workcontent] ,b.Username,b.Usercheng FROM Works as a join userinfo as b on a.Userid=b.Userid where Worksid=" + id + ""; SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand command = new SqlCommand(str, con); SqlDataReader reader = command.ExecuteReader(); WorksModel mm = new WorksModel(); while (reader.Read()) { mm.Worksid = Convert.ToInt32(reader["Worksid"].ToString()); mm.Worksname = reader["Worksname"].ToString(); mm.Bra = reader["Bra"].ToString(); mm.Size = Convert.ToInt32(reader["Size"].ToString()); mm.thickness = reader["thickness"].ToString(); mm.Worksdate = Convert.ToDateTime(reader["Worksdate"].ToString()); mm.Worksstate = Convert.ToInt32(reader["Worksstate"].ToString()); mm.Worksurl = reader["Worksurl"].ToString(); mm.WorksCount = Convert.ToInt32(reader["WorksCount"].ToString()); mm.Workcontent = reader["Workcontent"].ToString(); mm.Username = reader["Username"].ToString(); mm.Usercheng = reader["Usercheng"].ToString(); } con.Close(); return(mm); }
public ActionResult Edit(string id, WorksModel collection, List <HttpPostedFileBase> Img) { var mValue = collection.WorksModuleList.Where(m => m.Material.MenuID == -1).ToList(); foreach (var _value in mValue) { collection.WorksModuleList.Remove(_value); } if (string.IsNullOrEmpty(collection.Remarks)) { collection.Remarks = ""; } collection.UploadWorksFiles = Img; collection.WorksNo = id; if (collection.Update()) { return(RedirectToAction("Index")); } CreateSelect(); return(View(collection)); }
/// <summary> /// 作品表的添加 /// </summary> /// <returns></returns> public int WorksADD(WorksModel mm) { string str = string.Format(@"INSERT INTO [dbo].[Works] ([Worksname] ,[Bra] ,[Size] ,[thickness] ,[Worksdate] ,[Worksstate] ,[Worksurl] ,[WorksCount] ,[Workcontent] ,[Userid]) VALUES ('{0}','{1}',{2}'','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", mm.Worksname, mm.Bra, mm.Size, mm.thickness, mm.Worksdate, mm.Worksstate, mm.Worksurl, mm.WorksCount, mm.Workcontent, mm.Userid); SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand com = new SqlCommand(str, con); int i = com.ExecuteNonQuery(); con.Close(); return(i); }
/// <summary> /// 作品表的修改 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int WorksUpdate(WorksModel mm) { string str = string.Format(@"UPDATE [dbo].[Works] SET [Worksname] = '{0}', [Bra] = '{1}', [Size] = '{2}', [thickness] = '{3}', [Worksdate] = '{4}', [Worksstate] = '{5}', [Worksurl] = '{6}', [WorksCount] = '{7}', [Workcontent] = '{8}', [Userid] = '{9}' WHERE Worksid = '{10}'" , mm.Worksname, mm.Bra, mm.Size, mm.thickness, mm.Worksdate, mm.Worksstate, mm.Worksurl, mm.WorksCount, mm.Workcontent, mm.Userid, mm.Worksid); SqlConnection con = new SqlConnection(conString); con.Open(); SqlCommand com = new SqlCommand(str, con); int i = com.ExecuteNonQuery(); con.Close(); return(i); }
/// <summary> /// 作品表的删除 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int WorksDelete(WorksModel mm) { return(dal.WorksDelete(mm)); }
// GET: Works/Details/5 public ActionResult DetailfoC(string id, string p = "") { WorksModel value = null; PackagesModel _PackagesModel = null; WorksDetailViewModel model = null; if (!string.IsNullOrEmpty(id)) { value = WorksModel.GetWorksModelDetail(id); _PackagesModel = PackagesModel.GetPackageDetail(p); List <string> Worksize = new List <string>();; foreach (var mod in value.WorksModuleList) { string str_Size = ""; List <string> _SizeList = new List <string>(); string m = mod.Material.MenuName + " "; if (mod.Height > 0.0) { _SizeList.Add(mod.Height.ToString()); } if (mod.Width > 0.0) { _SizeList.Add(mod.Width.ToString()); } if (mod.Deep > 0.0) { _SizeList.Add(mod.Deep.ToString()); } if (_SizeList.Count > 0) { str_Size = string.Join("x", _SizeList.ToArray()) + "cm"; } //string h = mod.Height > 0.0 ? "" + mod.Height.ToString() + " x " : ""; //string w = mod.Width > 0.0 ? "" + mod.Width.ToString() + " x " : ""; //string d = mod.Deep > 0.0 ? "" + mod.Deep.ToString() + "cm " : ""; string t = mod.TimeLength.Length > 0 ? "影片長度:" + mod.TimeLength : ""; string c = mod.Amount > 1 ? " " + mod.Amount + mod.CountNoun.MenuName : ""; Worksize.Add(m + str_Size + t + c); } model = new WorksDetailViewModel() { PackagesNo = p, WorksNo = value.WorksNo, WorksName = value.WorksName, AuthorsName = string.Join(",", value.WorksAuthors.Select(a => a.MenuName)), MaterialsName = Worksize, Remarks = value.Remarks, Owner = string.Join(",", value.WorksPropOwnerList.Select(o => o.MenuName)), PropWare = string.Join(",", value.WorksPropWareTypeList.Select(o => o.MenuName)), Cost = value.Cost.ToString("#,#"), Price = value.Price.ToString("#,#"), PricingDate = value.PricingDate.ToString("yyyy-MM-dd"), GrossMargin = value.GrossMargin.ToString() + " %", GenreNo = string.Join(",", value.WorksPropGenreList.Select(o => o.MenuName)), PropStyle = string.Join(",", value.WorksPropStyleList.Select(o => o.MenuName)), Years = value.YearStart.ToString() + (value.YearStart == value.YearEnd ? "" : " ~ " + value.YearEnd.ToString()), WordsRating = value.Rating, EndDate = _PackagesModel.EndDate.Value }; } return(View(model)); }
/// <summary> /// 作品表的添加 /// </summary> /// <returns></returns> public int WorksADD(WorksModel mm) { return(dal.WorksADD(mm)); }
protected WorksFacade(WorksModel model) : base(model) { }
/// <summary> /// 作品表的修改 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int WorksUpdate(WorksModel mm) { return(dal.WorksUpdate(mm)); }
public static void 新增作品(匯入資料 _匯入資料) { if (!_匯入資料.藝術家中文名稱.Contains(";")) { List <string> _作品風格 = 分割文字(_匯入資料.作品風格); List <string> StyleNoList = new List <string>(); StyleNoList.Add("1"); List <string> _作品類型 = 分割文字(_匯入資料.作品類型); List <string> GenreNoList = new List <string>(); GenreNoList.Add("1"); List <string> _作品所有人 = 分割文字(_匯入資料.作品所有人); List <string> OwnerNoList = new List <string>(); OwnerNoList.Add("1"); List <string> _作品庫別 = 分割文字(_匯入資料.作品庫別); List <string> WareTypeNoList = new List <string>(); WareTypeNoList.Add("1"); List <string> _作品藝術家 = 分割文字(_匯入資料.藝術家中文名稱); List <string> AuthorsNoList = new List <string>(); AuthorsNoList.Add("1"); List <WorksModel.WorksModuleModel> WorksModuleModelList = new List <WorksModel.WorksModuleModel>(); using (var context = new EG_MagicCubeEntities()) { string _作品編號 = 處理文字(_匯入資料.作品編號); var _Works = context.Works.AsQueryable().Where(c => c.MaterialsID == _作品編號).Select(c => c).FirstOrDefault(); if (_Works == null) { var _匯入資料List = 匯入資料List.Where(c => c.作品編號 == _匯入資料.作品編號).Select(c => c).ToList(); //風格 var 風格List = _匯入資料List.Select(c => c.作品風格).ToList(); if (風格List != null && 風格List.Count > 0) { foreach (string str in 風格List) { _作品風格 = 處理標籤(_作品風格, str, true); } if (_作品風格 != null && _作品風格.Count > 0) { var _Array = context.Menu_Style.AsQueryable().Where(c => _作品風格.Contains(c.StyleName)).Select(c => c.StyleNo).ToList(); if (_Array != null && _Array.Count > 0) { StyleNoList = _Array.Select(c => c.ToString()).ToList(); } } } var 類型List = _匯入資料List.Select(c => c.作品類型).ToList(); if (類型List != null && 類型List.Count > 0) { foreach (string str in 類型List) { _作品類型 = 處理標籤(_作品類型, str, true); } if (_作品類型 != null && _作品類型.Count > 0) { var _Array = context.Menu_Genre.AsQueryable().Where(c => _作品類型.Contains(c.GenreName)).Select(c => c.GenreNo).ToList(); if (_Array != null && _Array.Count > 0) { GenreNoList = _Array.Select(c => c.ToString()).ToList(); } } } var 所有人List = _匯入資料List.Select(c => c.作品所有人).ToList(); if (所有人List != null && 所有人List.Count > 0) { foreach (string str in 所有人List) { _作品所有人 = 處理標籤(_作品所有人, str, true); } if (_作品所有人 != null && _作品所有人.Count > 0) { var _Array = context.Menu_Owner.AsQueryable().Where(c => _作品所有人.Contains(c.OwnerName)).Select(c => c.OwnerNo).ToList(); if (_Array != null && _Array.Count > 0) { OwnerNoList = _Array.Select(c => c.ToString()).ToList(); } } } var 庫別List = _匯入資料List.Select(c => c.作品庫別).ToList(); if (庫別List != null && 庫別List.Count > 0) { foreach (string str in 庫別List) { _作品庫別 = 處理標籤(_作品庫別, str, true); } if (_作品庫別 != null && _作品庫別.Count > 0) { var _Array = context.Menu_WareType.AsQueryable().Where(c => _作品庫別.Contains(c.WareTypeName)).Select(c => c.WareTypeNo).ToList(); if (_Array != null && _Array.Count > 0) { WareTypeNoList = _Array.Select(c => c.ToString()).ToList(); } } } var 藝術家List = _匯入資料List.Select(c => c.藝術家中文名稱).ToList(); if (藝術家List != null && 藝術家List.Count > 0) { foreach (string str in 藝術家List) { _作品藝術家 = 處理標籤(_作品藝術家, str, true); } if (_作品藝術家 != null && _作品藝術家.Count > 0) { var _Array = context.Authors.AsQueryable().Where(c => _作品藝術家.Contains(c.AuthorsCName)).Select(c => c.AuthorsNo).ToList(); if (_Array != null && _Array.Count > 0) { AuthorsNoList = _Array.Select(c => c.ToString()).ToList(); } } } foreach (匯入資料 mm in _匯入資料List) { WorksModel.WorksModuleModel _WorksModuleModel = new WorksModel.WorksModuleModel(); int _Amount = 1; int.TryParse(處理文字(mm.數量), out _Amount); _WorksModuleModel.Amount = _Amount; int _CountNounNo = context.Menu_CountNoun.AsQueryable().Where(c => c.CountNounName == mm.單位詞).Select(c => c.CountNounNo).FirstOrDefault(); if (_CountNounNo == 0) { _CountNounNo = 1; } _WorksModuleModel.CountNoun = new MenuViewModel() { MenuID = _CountNounNo }; int _MaterialNo = context.Menu_Material.AsQueryable().Where(c => c.MaterialName == mm.媒材).Select(c => c.MaterialNo).FirstOrDefault(); if (_MaterialNo == 0) { _MaterialNo = 1; } _WorksModuleModel.Material = new MenuViewModel() { MenuID = _MaterialNo }; double _Height = 0.0; double.TryParse(處理文字(mm.高度), out _Height); _WorksModuleModel.Height = _Height; double _Width = 0.0; double.TryParse(處理文字(mm.寬度), out _Width); _WorksModuleModel.Width = _Width; double _Deep = 0.0; double.TryParse(處理文字(mm.深度), out _Deep); _WorksModuleModel.Deep = _Deep; _WorksModuleModel.Length = 0; _WorksModuleModel.Measure = 處理文字(mm.計算尺寸); _WorksModuleModel.TimeLength = 處理文字(mm.錄像長度); WorksModuleModelList.Add(_WorksModuleModel); } WorksModel _WorksModel = new WorksModel(); _WorksModel.MaterialsID = 處理文字(_匯入資料.作品編號); _WorksModel.AuthorsNo = -1; _WorksModel.WorksName = 處理文字(_匯入資料.作品名稱); short _YearStart = 0; short.TryParse(處理文字(_匯入資料.作品年代起), out _YearStart); _WorksModel.YearStart = _YearStart; short _YearEnd = 0; short.TryParse(處理文字(_匯入資料.作品年代迄), out _YearEnd); _WorksModel.YearEnd = _YearEnd; int _Cost = 0; int.TryParse(處理文字(_匯入資料.成本), out _Cost); _WorksModel.Cost = _Cost; int _Price = 0; int.TryParse(處理文字(_匯入資料.定價), out _Price); _WorksModel.Price = _Price; _WorksModel.GrossMargin = Math.Round((((Convert.ToDouble((_Price / double.Parse("1.05"))) - Convert.ToDouble(_Cost)) / Convert.ToDouble((_Price / double.Parse("1.05")))) * Convert.ToDouble(100)), 3); _WorksModel.PricingDate = DateTime.Parse("2017/09/10"); double _Artisticability = 0.0; double.TryParse(處理文字(_匯入資料.藝術性), out _Artisticability); _WorksModel.Artisticability = _Artisticability; double _Marketability = 0.0; double.TryParse(處理文字(_匯入資料.市場性), out _Marketability); _WorksModel.Marketability = _Marketability; double _Packageability = 0.0; double.TryParse(處理文字(_匯入資料.包裹性), out _Packageability); _WorksModel.Packageability = _Packageability; double _Valuability = 0.0; double.TryParse(處理文字(_匯入資料.增值性), out _Valuability); _WorksModel.Valuability = _Valuability; _WorksModel.CreateUser = "******"; _WorksModel.CreateDate = DateTime.Now; _WorksModel.ModifyUser = "******"; _WorksModel.ModifyDate = DateTime.Now; _WorksModel.Remarks = 處理文字(_匯入資料.備註); //藝術家 _WorksModel.AuthorNo_InputString = AuthorsNoList; //類型 _WorksModel.GenreNo_InputString = GenreNoList; //風格 _WorksModel.StyleNo_InputString = StyleNoList; //擁有者 _WorksModel.OwnerNo_InputString = OwnerNoList; //庫別 _WorksModel.WareTypeNo_InputString = WareTypeNoList; //組件 _WorksModel.WorksModuleList = WorksModuleModelList; //圖片 Console.WriteLine(JsonConvert.SerializeObject(_WorksModel)); _WorksModel.Create(); } } } }