protected void btnSearchc_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCategNumber.Text)) { lblErrorMessage.Text = "Please Insert the Category Number"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } else { int id = int.Parse(txtCategNumber.Text); tblCategory = adpCategory.GetDataBy(id); Cache["tblCategory"] = tblCategory; var row = tblCategory; if (row.Count > 0) { if (row != null) { string name = row[0].CategoryName.ToString(); txtCategName.Text = name.Trim(); } } else { lblErrorMessage.Text = " Department ID " + id + " is not found"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } } }
public async Task <IActionResult> Edit(int id, [Bind("TableCategoryId,TableCapacity")] TableCategory tableCategory) { if (id != tableCategory.TableCategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tableCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TableCategoryExists(tableCategory.TableCategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tableCategory)); }
public void MyInit(DBLayer db, List <TableBase> tables, TableCategory tableName, MainWindow mainWindow) { _db = db; Tables = tables; _tableName = tableName; _mainWindow = mainWindow; }
private void refresh() { tblCategory = adpCategory.GetData(); Cache["tblCategory"] = tblCategory; grdCategory.DataSource = tblCategory; grdCategory.DataBind(); }
public static async Task UpdateCategory(this AppDbContext db, TableCategory category) { if (await category.Validate(db)) { db.TableCategories.Update(category); await db.SaveChangesAsync(); } }
public async Task <IActionResult> Create([Bind("TableCategoryId,TableCapacity")] TableCategory tableCategory) { if (ModelState.IsValid) { _context.Add(tableCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tableCategory)); }
protected void Update_Click(object sender, EventArgs e) { tblCategory = adpCategory.GetData(); Cache["tblCategory"] = tblCategory; int id = 0; string categ = txtCategName.Text; if (string.IsNullOrEmpty(txtCategNumber.Text)) { lblErrorMessage.Text = "Please Insert the Category Number"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } else { if (string.IsNullOrEmpty(categ)) { lblErrorMessage.Text = "Please Enter a Category Name"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } else { try { id = int.Parse(txtCategNumber.Text); } catch (Exception ex) { lblErrorMessage.Text = "Please Enter a Category Number"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; txtCategNumber.Focus(); } int result = adpCategory.Update(categ, id); if (result == 1) { lblErrorMessage.Text = "Department Update "; lblErrorMessage.ForeColor = System.Drawing.Color.Yellow; txtCategName.Text = ""; txtCategNumber.Text = ""; refresh(); } else { lblErrorMessage.Text = "Department NOT Update"; lblErrorMessage.ForeColor = System.Drawing.Color.Red; } } } }
private void Refresh() { tblCategory = adpCategory.GetData(); Cache["tblCategory"] = tblCategory; ddlCategory.DataSource = tblCategory; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryId"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem("Select a Category", "-1")); tblCategProduct = adpCategProduct.GetData(); Cache["tblCategProduct"] = tblCategProduct; grdCategProduct.DataSource = tblCategProduct; grdCategProduct.DataBind(); }
public bool createCategory(Category categoryToCreate) { //i don't need a transaction since i do only one insert operation //submitChanges manages rollback try { TableCategory createdCategory = new TableCategory(categoryToCreate.name); this.connection.categories.InsertOnSubmit(createdCategory); connection.SubmitChanges(); } catch (Exception e) { return(false); } return(true); }
private void Refresh() { tblOrdercf = adpOrdercf.GetDataMax(); Cache["tblOrderfc"] = tblOrdercf; createOrder(); txtQuantity.Text = "1"; tblCategory = adpCategory.GetData(); ddlCategoryProd.DataSource = tblCategory; ddlCategoryProd.DataTextField = "CategoryName"; ddlCategoryProd.DataValueField = "CategoryId"; ddlCategoryProd.DataBind(); ddlCategoryProd.Items.Insert(0, new ListItem("Select a Category", "-1")); txtSubtotal.Text = subTotal.ToString("C"); txtTax.Text = tax.ToString("C"); txtTotal.Text = total.ToString("C"); }
public static async Task <bool> Validate(this TableCategory category, AppDbContext db) { if (string.IsNullOrEmpty(category.Label)) { throw new Exception("A category must have a label"); } var check = await db.TableCategories .FirstOrDefaultAsync(x => x.Id != category.Id && x.Label.ToLower() == category.Label.ToLower() ); if (check != null) { throw new Exception($"Category {category.Label} already exists"); } return(true); }
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(); }
public async Task AddCategory([FromBody] TableCategory category) => await db.AddCategory(category);
public static async Task RemoveCategory(this AppDbContext db, TableCategory category) { db.TableCategories.Remove(category); await db.SaveChangesAsync(); }
public static async Task ToggleCategoryDeleted(this AppDbContext db, TableCategory category) { db.TableCategories.Attach(category); category.IsDeleted = !category.IsDeleted; await db.SaveChangesAsync(); }
public static void SetCategory(this DataTable table, TableCategory category) { table.ExtendedProperties["TABLE_CATEGORY"] = category.ToString(); }
public void PopulateTable(SurveyHelper.TableType table_type) { string table_name = null; switch (table_type) { case SurveyHelper.TableType.BS5837: table_name = "bs5837_table.txt"; break; case SurveyHelper.TableType.GeneralSurvey: table_name = "general_survey_table.txt"; break; default: return; } AssetManager assets = Application.Context.Assets; Table temp_table = new Table(); TableCategory temp_cat = new TableCategory(); using (StreamReader reader = new StreamReader(assets.Open(table_name))) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (isFileStart(line)) { while (reader.ReadLine() != "[End]") { } } else if (isTableStart(line)) { temp_table.name = reader.ReadLine(); } else if (isTableEnd(line)) { temp_table.categories.Add(temp_cat); //value_tables.Add(temp_table); SurveyHelper.values_tables.Add(temp_table); temp_table = new Table(); temp_cat = new TableCategory(); } else if (isTableCategory(line)) { if (temp_cat.items.Count() > 0) { temp_table.categories.Add(temp_cat); temp_cat = new TableCategory(); } temp_cat.category_name = line; } else if (isTableItem(line)) { temp_cat.items.Add(line); } else if (line == "[Topic]") { break; } } } }
public async Task UpdateCategory([FromBody] TableCategory category) => await db.UpdateCategory(category);
public async Task RemoveCategory([FromBody] TableCategory category) => await db.RemoveCategory(category);
public async Task ToggleCategoryDeleted([FromBody] TableCategory category) => await db.ToggleCategoryDeleted(category);