public static ResultSet CRUD(Cate cate, EntityState state) { using (AccDeficitEntities s = new AccDeficitEntities()) { s.Entry(cate).State = state; if (s.SaveChanges() > 0) { r.isSuccess = true; if (state == EntityState.Added) { r.Message = "Kategori sisteme başarıyla eklendi!"; } else if (state == EntityState.Modified) { r.Message = null; } else if (state == EntityState.Deleted) { r.Message = "Kategori silindi!"; } r.Cate = cate; r.iconType = IconType.ok; } else { r.isSuccess = false; r.Message = "Hata!!"; r.Cate = cate; r.iconType = IconType.warning; } return(r); } }
private void btnEliminar_Click(object sender, EventArgs e) { NegocioCategorias negCate = new NegocioCategorias(); Cate categoria = negCate.buscarCategoriaString(cmbCategoria.SelectedItem.ToString()); if (cmbCategoria.SelectedItem != null) { DialogResult opcion = 0; opcion = MessageBox.Show("¿Estás Seguro Que Quieres Eliminar Esta Categoría?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opcion == DialogResult.Yes) { NegocioCategorias negCategoria = new NegocioCategorias(); Cate cate = negCategoria.buscarCategoriaString(cmbCategoria.SelectedItem.ToString()); negCategoria.eliminarCategoria(cate._ID_Cate); this.Close(); MessageBox.Show("La Categoría Fue Eliminada Correctamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Error Debe Seleccionar Una Categoría Antes de Modificar el Nombre", "Error"); } }
public ActionResult NewOrEdit(int?id = 0) { var db = DB.Entities; Menu model = id == 0 ? new Menu() { Activated = true, ParentID = 0, Oder = 0 } : db.Menu.FirstOrDefault(m => m.ID == id); var lst = new List <Menu>(); var obj = new Menu() { ID = 0, Title = "None" }; lst.Add(obj); lst.AddRange(DB.Entities.Menu); ViewBag.dropDown = new SelectList(lst.ToList(), "ID", "Title", ""); var lstcate = new List <Cate>(); var objcate = new Cate() { ID = 0, Title = "None" }; lstcate.Add(objcate); lstcate.AddRange(DB.Entities.Cate); ViewBag.kenhtin = new SelectList(lstcate.ToList(), "ID", "Title", ""); return(View(model)); }
public static ResultSet CRUD(Customers cus, Cate cate, Products pro, Orders ord, Signin sign, EntityState state, string table) { ResultSet r = new ResultSet(); try { switch (table) { case "customer": r = HelperCustomer.CRUD(cus, state); break; case "category": r = HelperCate.CRUD(cate, state); break; case "product": r = HelperProduct.CRUD(pro, state); break; case "order": r = HelperOrder.CRUD(ord, state); break; case "signin": r = HelperSignin.CRUD(sign, state); break; default: break; } if (r.Message != null) { MessageBox.Show(r.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } return(r); } catch (Exception e) { r.Message = e.Message; } return(r); }
public ActionResult AdminEdit(Cate model) { var db = DB.Entities; try { if (model.ID == 0) { // Edit db.Cate.AddObject(model); } else { // Add new db.AttachTo("Cate", model); db.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); } if (string.IsNullOrEmpty(model.KeyUrl)) { model.KeyUrl = Common.CreateURLParam(model.Title); } model.LanguageID = CurrentLanguage.ID; db.SaveChanges(); return(RedirectToAction("AdminIndex")); } catch { return(View(model)); } }
public ActionResult DeleteConfirmed(int id) { Cate cate = db.Cates.Find(id); db.Cates.Remove(cate); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { if (id != 0) { Cate item = hel.GetEdit(id); return(View(item)); } return(View("AddNew")); }
public void writeCates() { Cate[] cateList = new Cate[9]; for (int i = 0; i < 9; i++) { CategoryManager cateMng = categoryContainer.transform.GetChild(i).GetComponent <CategoryManager>(); cateList[i] = new Cate(cateMng.getID(), cateMng.getName(), cateMng.getActive()); } WriteHandler.writeCategories(cateList); }
public void insertarCategoria(Cate cli) { this.configConex(); this.cnn._esSelect = true; this.cnn._sentenciaSQL = "insert into " + this.cnn._nombreTabla + " values(" + cli._ID_Cate + ",'" + cli._nombre + "')"; this.cnn.conectar(); this.cnn.cerrarConexion(); }
public ActionResult CateAdd(Cate cate) { ResultInfo resultInfo = new ResultInfo(1, "验证不通过"); if (ModelState.IsValid) { resultInfo = _cateService.Add(cate); } return Json(resultInfo); }
private void Exit_bn(object sender, RoutedEventArgs e) { var result = MessageBox.Show(@"Do you want to return to the Main Menu?", "Close Game", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { myMain = new MainWindow(); Cate.Hide(); myMain.Show(); } }
public void modificarCategoria(Cate cli) { this.configConex(); this.cnn._sentenciaSQL = "update " + cnn._nombreTabla + " set ID_Cate=" + cli._ID_Cate + "," + "nombre='" + cli._nombre + "'" + " where ID_Cate=" + cli._ID_Cate; this.cnn._esSelect = false; this.cnn.conectar(); this.cnn.cerrarConexion(); }
public ActionResult Edit([Bind(Include = "CateID,CateName,CateparentID")] Cate cate) { if (ModelState.IsValid) { db.Entry(cate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CateparentID = new SelectList(db.Cateparents, "CateparentID", "CateparentName", cate.CateparentID); return(View(cate)); }
void initalCategories() { Cate[] cateList = ReadHandler.readCategories(); for (int i = 0; i < 9; i++) { CategoryButton cateBtn = categoryContainer.transform.GetChild(i).GetComponent <CategoryButton>(); Cate cate = cateList[i]; Song[] songList = ReadHandler.readSongs(cate.ID); cateBtn.initial(cate.ID, cate.name, songList); } }
public ActionResult Create([Bind(Include = "CateID,CateName,CateparentID")] Cate cate) { if (ModelState.IsValid) { db.Cates.Add(cate); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CateparentID = new SelectList(db.Cateparents, "CateparentID", "CateparentName", cate.CateparentID); return(View(cate)); }
public void readCates() { Cate[] cateList = ReadHandler.readCategories(); for (int i = 0; i < 9; i++) { CategoryManager cateMng = categoryContainer.transform.GetChild(i).GetComponent <CategoryManager>(); Cate cate = cateList[i]; cateMng.setID(cate.ID); cateMng.setName(cate.name); cateMng.setToggle(cate.enabled); } }
public ActionResult AdminEdit(Post model, FormCollection frm, HttpPostedFileBase file) { try { var db = DB.Entities; Post obj = null; if (model.ID == 0) { obj = new Post(); obj.Created = DateTime.Now.Date; obj.UserID = CurrentUser.ID; obj.LanguageID = CurrentLanguage.ID; obj.Status = (int)PostStatus.Enabled; obj.Hot = true; obj.ViewCount = 0; obj.Deleted = false; } else { obj = db.Post.FirstOrDefault(m => m.ID == model.ID); } obj.Title = model.Title; obj.Summary = model.Summary; obj.Content = model.Content; obj.CateID = model.CateID; if (file != null) { var now = DateTime.Now; var fileName = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", now.Day, now.Hour, now.Minute, now.Second, now.Millisecond, CurrentUser.Email.Replace("@", "--")) + Path.GetExtension(file.FileName); file.SaveAs(Path.Combine(Server.MapPath("~/Uploads/"), fileName)); obj.ImageUrl = "/Uploads/" + fileName; } if (model.ID == 0) { db.Post.AddObject(obj); } db.SaveChanges(); } catch { var lstcate = new List <Cate>(); var objcate = new Cate() { ID = 0, Title = "None" }; lstcate.Add(objcate); lstcate.AddRange(DB.Entities.Cate); ViewBag.kenhtin = new SelectList(lstcate.ToList(), "ID", "Title", ""); return(View(model)); } return(RedirectToAction("AdminIndex")); }
public void cargarProductos() { NegocioCategorias negCli = new NegocioCategorias(); System.Collections.IEnumerator mostrar = negCli.getCate().GetEnumerator(); while (mostrar.MoveNext()) { Cate ca = (Cate)mostrar.Current; TabPage tab = new TabPage(); tab.Text = ca._nombre; tab.Name = ca._ID_Cate + ""; tbcProducts.Controls.Add(tab); } NegocioProducto negPro = new NegocioProducto(); IEnumerator tabpages = tbcProducts.TabPages.GetEnumerator(); while (tabpages.MoveNext()) { int izq = 10; int ar = 10; TabPage tab = (TabPage)tabpages.Current; ArrayList productos = negPro.getProductosxcate(int.Parse(tab.Name)); foreach (Producto itpro in productos) { Label lbl = new Label(); lbl.Name = itpro._ID_Producto + ""; lbl.Text = itpro._nombre; lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Width = 50; lbl.Left = izq; if (izq > tab.Width) { izq = 0; ar += 20; } lbl.Top = ar; AsignarEventos(lbl); tab.Controls.Add(lbl); izq += 50; } } }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cate cate = db.Cates.Find(id); if (cate == null) { return(HttpNotFound()); } return(View(cate)); }
public ActionResult AdminEdit(int?id = 0) { var obj = DB.Entities.Post.FirstOrDefault(m => m.ID == id); var lstcate = new List <Cate>(); var objcate = new Cate() { ID = 0, Title = "None" }; lstcate.Add(objcate); lstcate.AddRange(DB.Entities.Cate); ViewBag.kenhtin = new SelectList(lstcate.ToList(), "ID", "Title", ""); return(View(obj)); }
public override int GetHashCode() { int hash = 1; if (Cate != 0) { hash ^= Cate.GetHashCode(); } if (Key.Length != 0) { hash ^= Key.GetHashCode(); } hash ^= samples_.GetHashCode(); return(hash); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cate cate = db.Cates.Find(id); if (cate == null) { return(HttpNotFound()); } ViewBag.CateparentID = new SelectList(db.Cateparents, "CateparentID", "CateparentName", cate.CateparentID); return(View(cate)); }
private void NombreCategoria_Load(object sender, EventArgs e) { timer1.Start(); this.txtNombreCategoria.Select(); switch (Categoria.seleccion) { //Agregar Nueva Categoria case 1: cmbCategoria.Visible = false; btnModificar.Visible = false; btnEliminar.Visible = false; break; //Modificar Categoria case 2: cmbCategoria.Visible = true; btnModificar.Visible = true; btnAceptar.Visible = false; btnEliminar.Visible = false; NegocioCategorias negCategoria = new NegocioCategorias(); Cate categoria = negCategoria.buscarCategoria(Convert.ToInt32(lblID.Text)); cmbCategoria.SelectedValue = categoria; break; //Eliminar Categoria case 3: cmbCategoria.Visible = true; btnAceptar.Visible = false; btnModificar.Visible = false; NegocioCategorias negCategorias = new NegocioCategorias(); Cate categorias = negCategorias.buscarCategoria(Convert.ToInt32(lblID.Text)); cmbCategoria.SelectedValue = categorias; break; } ArrayList nombreBotones = Categoria.nombotones; foreach (string item in nombreBotones) { cmbCategoria.Items.Add(item); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product product = db.Products.Include(s => s.FileDetails).SingleOrDefault(x => x.ProductID == id); if (product == null) { return(HttpNotFound()); } Cate temp = db.Cates.Where(s => s.CateID == product.CateID).FirstOrDefault(); Cateparent temp2 = db.Cateparents.Where(s => s.CateparentID == product.CateparentID).FirstOrDefault(); ViewBag.Cateparent = temp.CateName; ViewBag.CateName = temp2.CateparentName; return(View(product)); }
public System.Collections.ArrayList getCate() { System.Collections.ArrayList lista = new System.Collections.ArrayList(); this.configConex(); this.cnn._sentenciaSQL = "Select * from " + cnn._nombreTabla; this.cnn._esSelect = true; this.cnn.conectar(); foreach (System.Data.DataRow dr in this.cnn._dbDataSet.Tables[this.cnn._nombreTabla].Rows) { Cate ca = new Cate(); ca._ID_Cate = int.Parse(dr["ID_Cate"].ToString()); ca._nombre = (string)dr["nombre"]; lista.Add(ca); } this.cnn.cerrarConexion(); return(lista); }
public ActionResult NewOrEdit(Menu model, FormCollection frm) { var db = DB.Entities; try { if (model.ID == 0) { // Edit db.Menu.AddObject(model); } else { // Add new db.AttachTo("Menu", model); db.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); } model.LanguageID = CurrentLanguage.ID; db.SaveChanges(); return(RedirectToAction("Index")); } catch { var lst = new List <Menu>(); var obj = new Menu() { ID = 0, Title = "None" }; lst.Add(obj); lst.AddRange(DB.Entities.Menu); ViewBag.dropDown = new SelectList(lst.ToList(), "ID", "Title", model.ParentID); var lstcate = new List <Cate>(); var objcate = new Cate() { ID = 0, Title = "None" }; lstcate.Add(objcate); lstcate.AddRange(DB.Entities.Cate); ViewBag.kenhtin = new SelectList(lstcate.ToList(), "ID", "Title", ""); return(View(model)); } }
public override int GetHashCode() { int hash = 1; if (Cate != 0) { hash ^= Cate.GetHashCode(); } if (Key.Length != 0) { hash ^= Key.GetHashCode(); } hash ^= samples_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void BtAddCate_Click(object sender, EventArgs e) { bool result = Helper.I(tbCateName.Text) || Helper.I(tbExp.Text); if (result) { MessageBox.Show("Tüm alanları doldurunuz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { List <string> list = new List <string>(); foreach (var item in HelperCate.GetCateList()) { list.Add(item.cateName); } if (list.Contains(tbCateName.Text)) { MessageBox.Show("Bu kategori sistemde kayıtlıdır!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Cate ct = new Cate { cateName = tbCateName.Text, explanation = tbExp.Text, addDate = DateTime.Now.Date }; r = Helper.CRUD(null, ct, null, null, null, EntityState.Added, "category"); if (r.isSuccess) { tbCateName.Clear(); tbExp.Clear(); DisplayCategories(); ComboBoxCateSources(); } } } }
public Cate buscarCategoriaString(string idCliente) { Cate cli = new Cate(); this.configConex(); this.cnn._sentenciaSQL = "Select * from " + cnn._nombreTabla + " where nombre = '" + idCliente + "'"; this.cnn._esSelect = true; this.cnn.conectar(); System.Data.DataTable dt = new System.Data.DataTable(); dt = cnn._dbDataSet.Tables[0]; try { cli._ID_Cate = int.Parse(dt.Rows[0][0].ToString()); cli._nombre = (string)dt.Rows[0][1]; } catch (Exception e) { cli._ID_Cate = 0; } this.cnn.cerrarConexion(); return(cli); }
public static void writeCategories(Cate[] cateList) { Debug.Log("writing..."); try { XDocument doc = XDocument.Load(PATH.CATEGORY + "category.xml"); List <XElement> xEleList = doc.Root.Elements("category").ToList(); for (int i = 0; i < 9; i++) { XElement xEle = xEleList[i]; Cate cate = cateList[i]; xEle.Attribute("id").Value = cate.ID; xEle.Value = cate.name.Trim(); xEle.Attribute("enabled").Value = cate.enabled.ToString(); } doc.Save(PATH.CATEGORY + "category.xml"); } catch (System.Exception e) { Debug.Log(e.ToString()); WriteHandler.writeDefault(); } }
private void btnAceptar_Click(object sender, EventArgs e) { if (txtNombreCategoria.Text.Equals("")) { MessageBox.Show("Debe Ingresar un nombre para la categoria", "Error de Ingreso"); } else { lblID.Text = (i).ToString(); NegocioCategorias negCategoria = new NegocioCategorias(); NegocioProducto negProducto = new NegocioProducto(); Cate categoria = negCategoria.buscarCategoriaString(txtNombreCategoria.Text.Trim()); if (categoria._nombre.Equals(txtNombreCategoria.Text.Trim())) { MessageBox.Show("Ya existe una categoria con el nombre " + txtNombreCategoria.Text); } else { Cate cate = new Cate(); Producto pro = new Producto(); nombreCategoria = txtNombreCategoria.Text.Trim(); MessageBox.Show(nombreCategoria); cate._nombre = nombreCategoria; cate._ID_Cate = Convert.ToInt32(lblID.Text); pro._categoria = Convert.ToInt32(lblID.Text); negCategoria.insertarCategoria(cate); this.Close(); } } }
public ActionResult CateEdit(Cate cate) { ResultInfo resultInfo = new ResultInfo(1, "验证不通过"); if (ModelState.IsValid) { Cate oldCate = _cateService.GetById(cate.CateId); if (oldCate == null) { resultInfo = new ResultInfo(1, "该信息已被删除或不存在,请刷新列表!"); return Json(resultInfo); } int oldPid = oldCate.Pid; oldCate.CateId = cate.CateId; oldCate.CateName = cate.CateName; oldCate.Pid = cate.Pid; resultInfo = _cateService.Update(oldCate, oldPid); } return Json(resultInfo); }
/// <summary> /// 更新类目文件 /// </summary> /// <param name="rootCate"></param> public void RenewCats(Cate[] rootCate) { // //TODO:Cate update // }