protected void btnSave_Click(object sender, EventArgs e) { string date1 = DateTime.Now.ToString("ddMMyyyyHHmmss"), date2 = DateTime.Now.ToString("ddMMyyyyHHmmss");; string filename = ""; var n = new tGallery(); n.GalleryName = txtName.Text.Trim(); n.Content = fckContent.Value; n.CreateAt = DateTime.Now; n.CreateBy = int.Parse(Session["cm_userId"].ToString()); n.Description = txtDescription.Text.Trim(); if (fuImage.HasFile) { filename = fuImage.FileName.Trim(); n.Image1 = "/upload/gallery/" + date1 + "_" + filename.Substring(filename.LastIndexOf('.')); } if (fuImage2.HasFile) { date2 = DateTime.Now.ToString("ddMMyyyyHHmmss"); filename = fuImage2.FileName.Trim(); n.Image2 = "/upload/gallery/" + date2 + "_" + filename.Substring(filename.LastIndexOf('.')); } n.Status = byte.Parse(dlActive.SelectedValue); n.BranchTypeId = int.Parse(dlBranchType.SelectedValue); db.tGalleries.InsertOnSubmit(n); db.SubmitChanges(); if (fuImage.HasFile) { if (dlBranchType.SelectedValue == "1") { fuImage.SaveAs(Server.MapPath("/upload/cnice/gallery/" + date1 + "_" + filename.Substring(filename.LastIndexOf('.')))); } else if (dlBranchType.SelectedValue == "2") { fuImage.SaveAs(Server.MapPath("/upload/cfashion/gallery/" + date1 + "_" + filename.Substring(filename.LastIndexOf('.')))); } } if (fuImage2.HasFile) { if (dlBranchType.SelectedValue == "1") { fuImage2.SaveAs(Server.MapPath("/upload/cnice/gallery/" + date2 + "_" + filename.Substring(filename.LastIndexOf('.')))); } else if (dlBranchType.SelectedValue == "2") { fuImage2.SaveAs(Server.MapPath("/upload/cfashion/gallery/" + date2 + "_" + filename.Substring(filename.LastIndexOf('.')))); } } txtDescription.Text = ""; txtName.Text = ""; fckContent.Value = ""; Response.Redirect("/gallery"); }
protected void btnSave_Click(object sender, EventArgs e) { if (fckContent.Value.Trim() != "") { string id = hdProductId.Value; var p = from x in db.tProducts where x.Id == int.Parse(id.Trim()) select x; if (p.Count() > 0) { p.FirstOrDefault().Content = fckContent.Value.Trim(); db.SubmitChanges(); Response.Redirect("/image"); } } }
protected void btnSave_Click(object sender, EventArgs e) { string date = DateTime.Now.ToString("ddMMyyyyHHmmss"); string filename = ""; var n = new tNew(); n.Body = fckContent.Value; n.CreateAt = DateTime.Now; n.CreateBy = int.Parse(Session["cm_userId"].ToString()); n.Type = byte.Parse(dlMenu.SelectedValue); n.Description = txtDescription.Text.Trim(); if (fuImage.HasFile) { filename = fuImage.FileName.Trim(); n.Image = "/upload/news/" + date + "_" + filename.Substring(filename.LastIndexOf('.')); } n.Status = byte.Parse(dlActive.SelectedValue); n.Tag = txtTag.Text.Trim(); n.Title = txtTitle.Text.Trim(); n.BranchTypeId = int.Parse(dlBranchType.SelectedValue); db.tNews.InsertOnSubmit(n); db.SubmitChanges(); if (fuImage.HasFile) { if (dlBranchType.SelectedValue == "1") { fuImage.SaveAs(Server.MapPath("/upload/cnice/news/" + date + "_" + filename.Substring(filename.LastIndexOf('.')))); } else if (dlBranchType.SelectedValue == "2") { fuImage.SaveAs(Server.MapPath("/upload/cfashion/news/" + date + "_" + filename.Substring(filename.LastIndexOf('.')))); } } txtDescription.Text = ""; txtTag.Text = ""; txtTitle.Text = ""; fckContent.Value = ""; Response.Redirect("/news"); }