public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Collage collage) { if (id != collage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(collage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CollageExists(collage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(collage)); }
public IActionResult Create() { List <Collage> cityList = new List <Collage>(); string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; using (SqlConnection connection = new SqlConnection(connectionString)) { //SqlDataReader connection.Open(); string sql = "Select * From City"; SqlCommand command = new SqlCommand(sql, connection); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { Collage city = new Collage { Id = Convert.ToInt32(dataReader["Id"]), Code = Convert.ToString(dataReader["Code"]), Name = Convert.ToString(dataReader["Name"]) }; cityList.Add(city); } } connection.Close(); } ViewData["City"] = new SelectList(cityList, "Id", "Name"); return(View()); }
public static void Main() { int rows = 6; int cols = 6; Region[,] region = new Region[rows, cols]; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { region[i, j] = new Region(i * 100 + 100, i * 100 + 200, j * 100 + 100, j * 100 + 200); } } for (int i = 0; i < rows; i++) { Console.Write("\n"); for (int j = 0; j < cols; j++) { Console.Write(region[i, j].upLim + "-" + region[i, j].downLim + "x" + region[i, j].leftLim + "-" + region[i, j].rightLim + ", "); } Console.Write("\n"); } Collage collage = new Collage(cols, rows, region); while (collage.grow()) { collage.stitchNext(region); } }
public IActionResult Index() { List <Collage> collageList = new List <Collage>(); string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); string sql = "SELECT * FROM Collage"; SqlCommand command = new SqlCommand(sql, connection); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { Collage collage = new Collage { Id = Convert.ToInt32(dataReader["Id"]), Name = Convert.ToString(dataReader["Name"]), Code = Convert.ToString(dataReader["Code"]), CityId = Convert.ToInt32(dataReader["CityId"]) }; collageList.Add(collage); } } connection.Close(); } return(View(collageList)); }
public ActionResult DeleteConfirmed(int id) { Collage collage = db.Collages.Find(id); db.Collages.Remove(collage); db.SaveChanges(); return(RedirectToAction("Index")); }
public collageReview(int quantity, int subs, bool replaceable, bool freeOrNot, int mmddyyyy) : base(freeOrNot, mmddyyyy) { iCollage = false; bCollage = true; cCollage = false; thing = new bitCollage(quantity, subs, replaceable); attached = true; }
public ActionResult Edit([Bind(Include = "storyBlockId,storyBlockName,storyBlockCaption,storyBlockDescription,storyBlockLocation,storyBlockOrderNumber,archivalStatus,uploadDate,collageId,temp_string1,temp_string2,temp_int1,temp_int2")] StoryBlock storyBlock, HttpPostedFileBase clientUploadedFile) { storyBlock.uploadDate = DateTime.Now; StoryBlock StoryBlock_Temp = TempData["StoryBlock_Temp"] as StoryBlock; storyBlock.archivalStatus = StoryBlock_Temp.archivalStatus; string acceptedFileType = "image/jpeg,image/gif,image/tiff,image/png,image/jpg"; string imageName, image_Path, updated_Path; if (clientUploadedFile != null && clientUploadedFile.ContentLength > 0) // update image { if (acceptedFileType.Split(",".ToCharArray()).Contains(clientUploadedFile.ContentType)) { if (clientUploadedFile.ContentLength < 5000000) { imageName = System.IO.Path.GetFileName(clientUploadedFile.FileName); Collage collage1 = db.Collages.Find(storyBlock.collageId); image_Path = System.IO.Path.Combine(Server.MapPath(collage1.collageLocation), imageName); updated_Path = collage1.collageLocation + "/" + imageName; clientUploadedFile.SaveAs(image_Path); using (MemoryStream m_stream = new MemoryStream()) { clientUploadedFile.InputStream.CopyTo(m_stream); byte[] array = m_stream.GetBuffer(); } storyBlock.storyBlockLocation = updated_Path; if (ModelState.IsValid) { db.Entry(storyBlock).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.errorMessage = "The file to be uploaded is exceeding the size limit. Please upload a file lessthan 5MB"; } } else { ViewBag.errorMessage = "Please upload the following type of files: image/jpeg,image/gif,image/tiff,image/png,image/jpg"; } } else { storyBlock.storyBlockLocation = StoryBlock_Temp.storyBlockLocation; if (ModelState.IsValid) { db.Entry(storyBlock).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.collageId = new SelectList(db.Collages, "collageId", "collageName", storyBlock.collageId); TempData.Remove("StoryBlock_Temp"); return(View(storyBlock)); }
public collageReview(int quantity, int subs, int shift, bool freeOrNot, int mmddyyyy) : base(freeOrNot, mmddyyyy) { iCollage = false; bCollage = false; cCollage = true; thing = new cyclicCollage(quantity, subs, shift); attached = true; }
public bool UpdateColg(Collage colg) { dalBase.sql = "UPDATE db_collage SET collagename=@collagename WHERE collageid=@collageid"; dalBase.List_param = new List <MySqlParameter>() { new MySqlParameter("@collagename", colg.Name), new MySqlParameter("@collageid", colg.ID) }; return(dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE, true)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Collage collage) { if (ModelState.IsValid) { _context.Add(collage); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(collage)); }
private void test3() { Collage collage = new Collage(@"C:\Users\chance\Documents\Visual Studio 2015\Capstone\HollisC_Collage\SimpleCollage\SimpleCollage\images\Squares.bmp", @"C:\Users\chance\Documents\Visual Studio 2015\Capstone\HollisC_Collage\SimpleCollage\SimpleCollage\images"); collage.GenerateCollageLayout(false); //foreach (CollageImage ci in collage.CollageLayout) //{ // Console.WriteLine(ci.AvgRGB); //} }
//public void SetRoles() //{ // try // { // Role role = new Role // { // RoleID = 1, // RoleName = "Admin", // CreateDate = DateTime.Now, // MdifiedDate = DateTime.Now // }; // db.Roles.Add(role); // db.SaveChanges(); // } // catch (Exception ex) // { // ExceptionTracker.SendErrorToText(ex); // } //} public void SetCollageName(CollageBusinessModel collage) { Collage collageDetail = new Collage { CollageName = collage.CollageName, CreateDate = DateTime.Now, MdifiedDate = DateTime.Now }; adminDataBaseOperation.SetCollageetails(collageDetail); }
protected override byte[] JGetBytes(object obj) { Collage collage = obj as Collage; if (collage == null) { throw new TipoException(); } return(base.GetBytes(((IEnumerable <ImageFragment>)collage).ToArray())); }
public ActionResult ShowCollage(string Id = "") { int collageId = Convert.ToInt32(Id); Collage collage = new Collage(); using (var db = new PostEntities()) { string id = User.Identity.GetUserId(); collage = db.Collages.Where(x => x.Id == collageId).FirstOrDefault(); } return(View(collage)); }
//通过学院名下拉框显示学院信息 private void combCollageName_SelectedIndexChanged(object sender, EventArgs e) { if (combCollageName.Text == "") { txtCollageDescribe.Text = null; } else { Collage objCollage = objCollageService.GetCollageByCollageName(this.combCollageName.Text.Trim()); this.txtCollageDescribe.Text = objCollage.Remark.ToString(); } }
public FrmCollageUpdate(Collage objCollage) { InitializeComponent(); //初始化学院下拉框 this.combCollageName.DataSource = objCollageService.GetAllCollage(); this.combCollageName.DisplayMember = "CollageName"; this.combCollageName.ValueMember = "CollageID"; this.combCollageName.SelectedIndex = -1; this.combCollageName.SelectedIndexChanged += new System.EventHandler(this.combCollageName_SelectedIndexChanged); this.combCollageName.Text = objCollage.CollageName.ToString(); this.txtCollageRemakr.Text = objCollage.Remark.ToString(); }
public ActionResult CreateCollage(string user_id = "") { Session["CurrentUserId"] = User.Identity.GetUserId(); user_id = User.Identity.GetUserId(); Collage collage = new Collage(); collage.JSON = ""; using (var db = new PostEntities()) { collage.Photos = db.Images.Where(x => x.UserId == user_id).ToList(); } return(View(collage)); }
private static void MakeACollage() { //string template = @"C:\Users\chance\Documents\Visual Studio 2015\Capstone\HollisC_Collage\SimpleCollage\SimpleCollage\createdImages\Squares.bmp"; string template = @"C:\Users\chance\Pictures\MyDrawings\spaceneedle.jpg"; string source = @"C:\Users\chance\Documents\Visual Studio 2015\Capstone\HollisC_Collage\SimpleCollage\CollageTester\Images"; //string source = @"D:\Pictures 1"; Collage testcollage = new Collage(template, source, SimpleCollage.Enums.ImageSize.MedLarge, SimpleCollage.Enums.CollageSize.MedLarge); Console.WriteLine("Current time: " + sw.Elapsed); //testcollage.scaleTemplate(.5); testcollage.GenerateCollageLayout(true); testcollage.BuildCollage(@"C:\Users\chance\Documents\Visual Studio 2015\Capstone\HollisC_Collage\SimpleCollage\CollageTester\createdImages\NewScalingTest3.png"); }
public ActionResult Create([Bind(Include = "storyBlockId,storyBlockName,storyBlockCaption,storyBlockDescription,storyBlockLocation,storyBlockOrderNumber,archivalStatus,uploadDate,collageId,temp_string1,temp_string2,temp_int1,temp_int2")] StoryBlock storyBlock, HttpPostedFileBase clientUploadedFile) { storyBlock.uploadDate = DateTime.Now; storyBlock.archivalStatus = false; //storyBlock.storyBlockDescription = storyBlock.temp_string1; string acceptedFileType = "image/jpeg,image/gif,image/tiff,image/png,image/jpg"; //Accepts the mentioned file types for upload string imageName, image_Path, updated_Path; if (clientUploadedFile != null && clientUploadedFile.ContentLength > 0) //checks for empty files { if (acceptedFileType.Split(",".ToCharArray()).Contains(clientUploadedFile.ContentType)) // checks for valid extensions { if (clientUploadedFile.ContentLength < 5000000) // supports up to 5MB size files { imageName = System.IO.Path.GetFileName(clientUploadedFile.FileName); Collage collage1 = db.Collages.Find(storyBlock.collageId); image_Path = System.IO.Path.Combine(Server.MapPath(collage1.collageLocation), imageName); updated_Path = collage1.collageLocation + "/" + imageName; // stores image path as a static path along with image name clientUploadedFile.SaveAs(image_Path); using (MemoryStream m_stream = new MemoryStream()) // Creates a stream and store to memory { clientUploadedFile.InputStream.CopyTo(m_stream); byte[] array = m_stream.GetBuffer(); } storyBlock.storyBlockLocation = updated_Path; if (ModelState.IsValid) { db.StoryBlocks.Add(storyBlock); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.errorMessage = "The file to be uploaded is exceeding the size limit. Please upload a file lessthan 5MB"; } } else { ViewBag.errorMessage = "Please upload the following type of files: image/jpeg,image/gif,image/tiff,image/png,image/jpg"; } } else { ViewBag.errorMessage = "Please upload a non empty file"; } ViewBag.collageId = new SelectList(db.Collages, "collageId", "collageName", storyBlock.collageId); return(View(storyBlock)); }
//添加学院 private void btnAdd_Click(object sender, EventArgs e) { //判断信息是否为空 if (txtCollageName.Text.Trim().Length == 0) { MessageBox.Show("请填写学院名称!", "信息提示"); this.txtCollageName.Focus(); return; } //判断学院是否重复 if (this.objCollageService.IsCollageNameExisted(this.txtCollageName.Text.Trim())) { MessageBox.Show("学院已经存在!", "验证提示"); this.txtCollageName.Focus(); this.txtCollageName.SelectAll(); return; } //封装学院对象 Collage objCollage = new Collage() { CollageName = txtCollageName.Text.Trim(), Remark = txtCollageRemakr.Text }; //提交对象 try { int result = objCollageService.AddCollage(objCollage); if (result == 1) { DialogResult dresult = MessageBox.Show("添加成功!是否继续添加", "添加询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dresult == DialogResult.OK) { //清空当前的文本框 txtCollageName.Text = ""; txtCollageRemakr.Text = ""; } } else { MessageBox.Show("添加失败!", "添加提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult EditCollage(string Id = "") { int collageId = Convert.ToInt32(Id); Session["CurrentUserId"] = User.Identity.GetUserId(); var user_id = User.Identity.GetUserId(); Collage collage = new Collage(); using (var db = new PostEntities()) { collage = db.Collages.Where(x => x.Id == collageId).FirstOrDefault(); collage.Photos = db.Images.Where(x => x.UserId == user_id).ToList(); } return(View("EditCollage", collage)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Collage collage = db.Collages.Find(id); if (collage == null) { return(HttpNotFound()); } ViewBag.archival_stat = collage.archivalStatus; return(View(collage)); }
public ActionResult Edit([Bind(Include = "collageId,collageName,collageDescription,orderNumber,collageLocation,archivalStatus,uploadDate,storyId,temp_string1,temp_string2,temp_int1,temp_int2")] Collage collage) { collage.uploadDate = DateTime.Now; Collage collage_temp = TempData["Collage_Temp"] as Collage; collage.collageLocation = collage_temp.collageLocation; collage.archivalStatus = collage_temp.archivalStatus; if (ModelState.IsValid) { db.Entry(collage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.storyId = new SelectList(db.Stories, "storyId", "storyName", collage.storyId); return(View(collage)); }
public IActionResult Update(Collage collage) { string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; using (SqlConnection connection = new SqlConnection(connectionString)) { string sql = $"Update Collage SET Code='{collage.Code}', Name='{collage.Name}', CityId='{collage.CityId}' Where Id='{collage.Id}'"; using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); command.ExecuteNonQuery(); connection.Close(); } } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "collageId,collageName,collageDescription,orderNumber,collageLocation,archivalStatus,uploadDate,storyId,temp_string1,temp_string2,temp_int1,temp_int2")] Collage collage) { Story story = db.Stories.Find(collage.storyId); collage.collageLocation = story.storyLocation; collage.uploadDate = DateTime.Now; collage.archivalStatus = false; if (ModelState.IsValid) { db.Collages.Add(collage); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.storyId = new SelectList(db.Stories, "storyId", "storyName", collage.storyId); return(View(collage)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Collage collage = db.Collages.Find(id); if (collage == null) { return(HttpNotFound()); } ViewBag.archival_stat = collage.archivalStatus; ViewBag.storyId = new SelectList(db.Stories, "storyId", "storyName", collage.storyId); TempData["Collage_Temp"] = collage; return(View(collage)); }
public ActionResult DeleteCollage(int Id) { var db = new PostEntities(); Collage b = db.Collages.Find(Id); if (b != null) { string[] path = b.Path.Split('/', '.').ToArray(); Account account = new Account( "fogolan", "393293335414884", "N7O41a-Nl9VpX4nDuzGagsUxeFA"); Cloudinary cloudinary = new Cloudinary(account); cloudinary.DeleteResources(path[5]); db.Collages.Remove(b); db.SaveChanges(); } return(RedirectToAction("ShowCollages")); }
private bool AddGroup(string arabic_name, string english_name) { try { db.Configuration.LazyLoadingEnabled = false; Collage group = db.Collages.Create(); group.Collage_Name_Ar = arabic_name; group.Collage_Name_En = english_name; db.Collages.Add(group); db.SaveChanges(); /* Add it to log file */ LogData = "data:" + JsonConvert.SerializeObject(group, logFileModule.settings); logFileModule.logfile(10, "إنشاء كلية جديدة", "create new Colleges", LogData); db.Entry(group).Reload(); CollegeDataSource.DataBind(); } catch { return(false); } return(true); }
/// <summary> /// 修改学院信息 /// </summary> /// <param name="objCollage"></param> /// <returns></returns> public int UpdateCollage(Collage objCollage) { string sql = "UPDATE [dbo].[tbCollageInfo]SET" + "[CollageName] ='" + objCollage.CollageName + @"' ,[Remark] = '" + objCollage.Remark + @"' WHERE CollageName = '" + objCollage.CollageName + @"'"; try { return(Convert.ToInt32(SQLHelper.Update(sql)));//执行sql语句,返回结果 } catch (SqlException ex) { throw new Exception("数据库操作异常!具体信息:\r\n" + ex.Message); } catch (Exception ex) { throw ex; } }
/// <summary> /// 添加学院对象 /// </summary> /// <param name="objCollage"></param> /// <returns></returns> public int AddCollage(Collage objCollage) { Collage collage = new Collage(); string sql = @"INSERT INTO[dbo].[tbCollageInfo] ([CollageName] ,[Remark]) VALUES ('" + objCollage.CollageName + @"' ,'" + objCollage.Remark + "')"; try { return(SQLHelper.Update(sql)); } catch (Exception ex) { throw new Exception("保存数据出现问题!" + ex.Message); } }