void saveButton_Click(object sender, EventArgs e) { categoryId = Int32.Parse(idHidden.Value); String name = nameBox.Text.Trim(); if (name == String.Empty) { ErrorMessage = "Name cannot be blank"; return; } CategoryTableAdapter categoryAdapter = new CategoryTableAdapter(); if (categoryId > 0) { category = categoryAdapter.GetCategory(categoryId)[0]; category.Name = name; categoryAdapter.Update(category); parentCategoryId = category.ParentCategoryId; } else if (isNew == true && isSubCategory == false && Request.QueryString["parent_id"] == "NEW") { categoryAdapter.Insert(StationId, null, name, -1); } else { parentCategoryId = Int32.Parse(parentIdHidden.Value); // SeqNo of -1 will assign it the next highest SeqNo for the category categoryAdapter.Insert(StationId, parentCategoryId, name, -1); } InfoMessage = "Category Updated"; if (parentCategoryId > 0) { Response.Redirect("~/admin/CategoryEdit.aspx?id=" + parentCategoryId); } else { Response.Redirect("~/admin/CategoryList.aspx"); } }
protected void saveButton_Click(object sender, EventArgs e) { string categoryName = txtCategory.Text.Trim(); if (string.IsNullOrEmpty(categoryName)) { txtCategoryValidator.ErrorMessage = "Category cannot be blank"; return; } CategoryTableAdapter categoryAdapter = new CategoryTableAdapter(); int categoryMatches = (int)categoryAdapter.ValidateCategoryName(categoryName); if (categoryMatches != 0) { ErrorMessage = "There's already a category created with that name"; return; } categoryAdapter.Insert(StationId, null, categoryName, -1); InfoMessage = "Category created"; Response.Redirect("~/admin/CategoryList.aspx"); }
protected void btnCat_Click(object sender, EventArgs e) { int result = adpCat.Insert(txtCat.Text); if (result == 1) { lblMessage.Text = "Author Inserted"; lblMessage.ForeColor = System.Drawing.Color.Green; RefreshGridView(); txtBookName.Text = txtAuthor.Text = txtQuantity.Text = txtPub.Text = txtISBN.Text = txtBookID.Text = txtCat.Text = ""; } else { lblMessage.Text = "Author is not inserted"; lblMessage.ForeColor = System.Drawing.Color.Red; } }
private void insertCategory(string categ) { tblCategory = adpCategory.GetData(); Cache["tblCategory"] = tblCategory; int result = adpCategory.Insert(categ); if (result == 1) { lblErrorMessage.Text = "Category Inserted "; lblErrorMessage.ForeColor = System.Drawing.Color.Yellow; txtCategName.Text = ""; txtCategNumber.Text = ""; } else { lblErrorMessage.Text = "Category NOT Inserted"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } refresh(); }
void saveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { StationTableAdapter stationAdapter = new StationTableAdapter(); String name = nameBox.Text.Trim(); int siteTypeId = Int32.Parse(siteTypeList.SelectedValue); int stationTypeId = Int32.Parse(stationTypeList.SelectedValue); String phoneNumber = phoneNumberBox.Text.Trim(); String address1 = address1Box.Text.Trim(); String address2 = address2Box.Text.Trim(); String city = cityBox.Text.Trim(); String stateCode = stateList.SelectedValue; String zipCode = zipCodeBox.Text.Trim(); int timeZoneId = Int32.Parse(timeZoneList.SelectedValue); //bool affectedByDST = daylightSavingsBox.Checked; String stationUrl = stationUrlBox.Text.Trim(); String siteName = siteNameBox.Text.Trim(); String content1 = content1Box.Text.Trim(); String content2 = content2Box.Text.Trim(); //bool isActive = isActiveBox.Checked; if (name == String.Empty) { ErrorMessage = "Name is required"; return; } if (phoneNumber == String.Empty) { ErrorMessage = "Phone Number is required"; return; } if (address1 == String.Empty) { ErrorMessage = "Address 1 is required"; return; } if (city == String.Empty) { ErrorMessage = "City is required"; return; } if (zipCode == String.Empty) { ErrorMessage = "Zip Code is required"; return; } if (stationUrl != String.Empty) { stationUrl = stationUrlStart.SelectedValue + stationUrl; // come up with a better validation... if (!Uri.IsWellFormedUriString(stationUrl, UriKind.Absolute)) { ErrorMessage = "Please enter a valid Station Website"; return; } } if (stationUrl.Length > 500) { stationUrl = stationUrl.Substring(0, 500); } /* * if (content1 == String.Empty) { * ErrorMessage = "Content 1 is required"; * return; * }*/ if (content1.Length > 1000) { content1 = content1.Substring(0, 1000); } /* * if (content2 == String.Empty) { * ErrorMessage = "Content 2 is required"; * return; * }*/ if (content2.Length > 1000) { content2 = content2.Substring(0, 1000); } siteName = siteName.Replace("<br />", ""); if (siteName.Length > 500) { siteName = siteName.Substring(0, 500); } String siteNameCheck = Regex.Replace(siteName, "<[^>]+>", "").Replace(" ", "").Trim(); if (siteNameCheck == String.Empty) // only leftover formatting in site name { siteName = String.Empty; } if (Station != null) { Station.Name = name; Station.SiteTypeId = Int32.Parse(siteTypeList.SelectedValue); Station.StationTypeId = Int32.Parse(stationTypeList.SelectedValue); Station.PhoneNumber = phoneNumber; Station.Address1 = address1; Station.Address2 = address2; Station.City = city; Station.StateCode = stateList.SelectedValue; Station.ZipCode = zipCode; Station.TimeZoneId = Int32.Parse(timeZoneList.SelectedValue); //Station.AffectedByDST = daylightSavingsBox.Checked; if (stationUrl != String.Empty) { Station.StationUrl = stationUrl; } else { Station.SetStationUrlNull(); } if (siteName != String.Empty) { Station.SiteName = siteName; } else { Station.SetSiteNameNull(); } Station.Content1 = content1; Station.Content2 = content2; //Station.IsActive = isActiveBox.Checked; Station.IsSiteActive = isSiteActiveBox.Checked; stationAdapter.Update(Station); InfoMessage = "Station Updated"; } else { if (IsSuperAdmin) { String code = codeBox.Text.Trim().ToUpper(); if (code == String.Empty) { ErrorMessage = "Code is required"; return; } if (code.Length < 3 || code.Length > 20) { ErrorMessage = "Code must be between 3 and 20 characters"; return; } DollarSaverDB.StationDataTable stationCodeLookup = stationAdapter.GetByCode(code); if (stationCodeLookup.Count == 1 && (Station == null || stationCodeLookup[0].StationId != Station.StationId)) { InfoMessage = "Code is already in use"; return; } int stationId = Convert.ToInt32(stationAdapter.InsertPK(name, code, stationTypeId, siteTypeId, phoneNumber, address1, address2, city, stateCode, zipCode, timeZoneId, false, DateTime.Now, DateTime.Now, true, content1, content2, Globals.ConvertToNull(stationUrl), Globals.ConvertToNull(siteName), isSiteActiveBox.Checked, null)); Station = stationAdapter.GetStation(stationId)[0]; CategoryTableAdapter categoryAdapter = new CategoryTableAdapter(); categoryAdapter.Insert(stationId, null, "Restaurants & Food", 1); categoryAdapter.Insert(stationId, null, "Things To Do", 2); categoryAdapter.Insert(stationId, null, "Home & Garden", 3); categoryAdapter.Insert(stationId, null, "Health & Beauty", 4); categoryAdapter.Insert(stationId, null, "Retail", 5); categoryAdapter.Insert(stationId, null, "Automotive", 6); StationContentTableAdapter stationContentTableAdapter = new StationContentTableAdapter(); stationContentTableAdapter.Insert(stationId, null, null, null, null, null, null, null, null, null); DealSettingsTableAdapter dealSettingsAdapter = new DealSettingsTableAdapter(); dealSettingsAdapter.Insert(stationId, 1, 8, 4, 10); SpecialSettingsTableAdapter specialSettingAdapter = new SpecialSettingsTableAdapter(); specialSettingAdapter.Insert(stationId, true); if (!Directory.Exists(Request.PhysicalApplicationPath + Station.StationDirUrl)) { Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.StationDirUrl); } if (!Directory.Exists(Request.PhysicalApplicationPath + Station.ImageDirUrl)) { Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.ImageDirUrl); } } } RedirectToHomePage(); } }
public void Insert(string categoryname) { _category.Insert(categoryname); }