public async Task <IHttpActionResult> getCategory(int categoryId) { System.Web.HttpContext.Current.Application.Lock(); DAL.Category category = _db.Categories.Where(p => p.id == categoryId).FirstOrDefault(); System.Web.HttpContext.Current.Application.UnLock(); return(Json(category)); }
public async Task <IHttpActionResult> search(DAL.Category model) { System.Web.HttpContext.Current.Application.Lock(); //var category = from m in _db.Categories select m; var category = from m in _db.Categories select new { id = m.id, categoryName = m.categoryName, status = m.status }; if (model.categoryName != null) { category = from m in category where m.categoryName.Contains(model.categoryName) select m; } if (model.status != 0) { category = from m in category where m.status == model.status select m; } category = from m in category orderby m.categoryName select m; System.Web.HttpContext.Current.Application.UnLock(); return(Json(category)); }
public static CategoryDTO ToDto(DAL.Category c) { return(new CategoryDTO() { categoryId = c.categoryId, categoryName = c.categoryName, parentCategoryId = c.parentCategoryId }); }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvCategory.SelectedRows.Count <= 0) { return; } DialogResult dr = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return; } DAL.Category c = new DAL.Category(); c.Id = Convert.ToInt32(dgvCategory.SelectedRows[0].Cells["colId"].Value); if (c.Delete()) { MessageBox.Show("Deleted"); btnSearch.PerformClick(); } else { MessageBox.Show(c.Error); } }
public string loadMenu(int pid = 0) { DAL.Category c = new DAL.Category(); System.Data.DataTable dt = new System.Data.DataTable(); if (pid <= 0) { dt = c.Select(" where c.categoryId is null").Tables[0]; } else { dt = c.Select(" where c.categoryId = " + pid.ToString()).Tables[0]; } if (pid > 0 && dt.Rows.Count > 0) { s += "<ul>\n\r"; } for (int i = 0; i < dt.Rows.Count; i++) { s += "<li><a href=\"Shop.aspx?category=" + dt.Rows[i].ItemArray[0] + "\">" + dt.Rows[i].ItemArray[1] + "</a>"; loadMenu(Convert.ToInt32(dt.Rows[i].ItemArray[0])); s += "</li>\n\r"; } if (pid > 0 && dt.Rows.Count > 0) { s += "</ul>\n\r"; } return(s); }
public string loadMenu(int pid = 0) { DAL.Category ctg = new DAL.Category(); try { System.Data.DataTable dt = ctg.SelectMenu(pid).Tables[0]; if (pid > 0 && dt.Rows.Count > 0) { menuHtml += "<ul>\n"; } for (int i = 0; i < dt.Rows.Count; i++) { menuHtml += "<li><a href=\"shop.aspx?category=" + dt.Rows[i].ItemArray[0].ToString() + "\">" + dt.Rows[i].ItemArray[1].ToString() + "</a>\n"; loadMenu(Convert.ToInt32(dt.Rows[i].ItemArray[0])); menuHtml += "</li>\n"; } if (pid > 0 && dt.Rows.Count > 0) { menuHtml += "</ul>\n"; } } catch { } return(menuHtml); }
private void frmProductNew_Load(object sender, EventArgs e) { DAL.Brand b = new DAL.Brand(); DAL.Category c = new DAL.Category(); cmbBrand.Source(b.Select()); cmbCategory.Source(c.Select()); MyControls.Helper.Numeric(txtDiscount); }
private void loadCategory() { DAL.Category category = new DAL.Category(); cmbCategory.DataSource = category.Select().Tables[0]; cmbCategory.DisplayMember = "name"; cmbCategory.ValueMember = "id"; cmbCategory.SelectedValue = -1; }
public void loadCategory(int cid = 0) { DAL.Category ctg = new DAL.Category(); System.Data.DataTable dt = ctg.SelectMenu(cid).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { ids += ", " + dt.Rows[i].ItemArray[0].ToString(); loadCategory((int)dt.Rows[i].ItemArray[0]); } }
private void frmProduct_Load(object sender, EventArgs e) { DAL.Brand b = new DAL.Brand(); cmbBrand.DataSource = b.Select().Tables[0]; cmbBrand.DisplayMember = "name"; cmbBrand.ValueMember = "id"; cmbBrand.SelectedValue = -1; DAL.Category c = new DAL.Category(); cmbCategory.DataSource = c.Select().Tables[0]; cmbCategory.DisplayMember = "name"; cmbCategory.ValueMember = "id"; cmbCategory.SelectedValue = -1; }
public async Task <IHttpActionResult> delete(int id) { Boolean result = true; try { System.Web.HttpContext.Current.Application.Lock(); DAL.Category category = _db.Categories.Where(p => p.id == id).FirstOrDefault(); _db.Categories.Remove(category); _db.SaveChanges(); System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { result = false; } return(Json(new { result = result })); }
public async Task <IHttpActionResult> update(Models.CategoryModel model) { if (!ModelState.IsValid) { return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) })); } Boolean result = true; try { System.Web.HttpContext.Current.Application.Lock(); DAL.Category nowCategory = _db.Categories.Where(p => p.id == model.id).FirstOrDefault(); nowCategory.categoryName = model.categoryName; nowCategory.status = model.status; _db.SaveChanges(); System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { result = false; } return(Json(new { result = result })); }
private void btnSearch_Click(object sender, EventArgs e) { DAL.Category category = new DAL.Category(); dgvCategory.DataSource = category.Select().Tables[0]; }
public CategoryModel(DAL.Category cat) { this.ID = cat.ID; this.Name = cat.Name; }