public void UpdateStock() { try { if (ViewState["StockId"] == null) { Response.Redirect("~/login.aspx"); } var stockId = int.Parse(ViewState["StockId"].ToString()); var stockObj = _db.Stocks.FirstOrDefault(m => m.StockID == stockId); stockObj.Name = txtName.Value; if (int.Parse(ddlVendor.SelectedValue) > 0) { stockObj.VendourId = int.Parse(ddlVendor.SelectedValue); } stockObj.VendourId = int.Parse(ddlVendor.SelectedValue); stockObj.Description = txtDescription.Text; stockObj.Code = txtBarcode.Text; stockObj.FilePath = UploadPicture(); _db.SaveChanges(); ErrorControl1.ShowSuccess("Stock Updated successfully"); divForm.Visible = false; divList.Visible = true; LoadStock(); } catch (Exception ex) { ErrorControl2.ShowError("An error occurred, please contact administrator"); } }
private bool ValidateControl() { if (string.IsNullOrEmpty(txtFullName.Text)) { ErrorControl2.ShowError("Name is Required"); return(false); } else if (string.IsNullOrEmpty(txtFullName.Text)) { ErrorControl2.ShowError("Company is Required"); return(false); } else if (string.IsNullOrEmpty(txtAddress.Text)) { ErrorControl2.ShowError("Address is required"); return(false); } else if (string.IsNullOrEmpty(txtPhone.Text)) { ErrorControl2.ShowError("Phone is required"); return(false); } else if (string.IsNullOrEmpty(txtEmail.Text)) { ErrorControl2.ShowError("Email is required"); return(false); } return(true); }
public void UpdateVendour() { try { if (ViewState["VendourId"] == null) { Response.Redirect("~/login.aspx"); } var vendourId = int.Parse(ViewState["VendourId"].ToString()); var instituionObj = _db.Vendours.FirstOrDefault(m => m.VendourId == vendourId); instituionObj.FullName = txtFullName.Text.Trim(); instituionObj.CompanyName = txtCompany.Text.Trim(); instituionObj.Address = txtAddress.Text.Trim(); instituionObj.Phone = txtPhone.Text.Trim(); instituionObj.Email = txtEmail.Text.Trim(); instituionObj.Website = txtAccountNo.Text.Trim(); instituionObj.AccountNumber = txtAccountNo.Text.Trim(); instituionObj.AccountName = txtAccountName.Text.Trim(); instituionObj.BankName = txtBankName.Text.Trim(); instituionObj.AccountType = int.Parse(ddlAccountType.SelectedValue); _db.SaveChanges(); ErrorControl1.ShowSuccess("Vendour Updated successfully"); divFormVend.Visible = false; divList.Visible = true; LoadVendour(); } catch (Exception ex) { ErrorControl2.ShowError("An error occurred, please contact administrator"); } }
private bool ValidateControl() { if (string.IsNullOrEmpty(txtName.Text)) { ErrorControl2.ShowError("Name is required"); return(false); } return(true); }
public void UpdateInventory() { try { if (ViewState["InventoryId"] == null) { Response.Redirect("~/login.aspx"); } var inventoryId = int.Parse(ViewState["InventoryId"].ToString()); var inventoryObj = _db.Inventories.FirstOrDefault(m => m.InventoryId == inventoryId); if (int.Parse(ddlStock.SelectedValue) > 0) { inventoryObj.StockId = (int.Parse(ddlStock.SelectedValue)); } inventoryObj.CostPrice = decimal.Parse(txtCostPrice.Text); inventoryObj.ReorderLevel = int.Parse(txtReoderLevel.Text); inventoryObj.Quantity = int.Parse(txtQuantity.Text); inventoryObj.DateCreated = DateTime.Now; if (chkRequired.Checked) { inventoryObj.Permision = true; } else { inventoryObj.Permision = false; } _db.SaveChanges(); ErrorControl1.ShowSuccess("Stock Updated successfully"); divFormIv.Visible = false; divList.Visible = true; LoadStock(); } catch (Exception ex) { ErrorControl2.ShowError("An error occurred, please contact administrator"); } }
public void UpdateCategory() { try { if (ViewState["CategoryId"] == null) { Response.Redirect("~/login.aspx"); } var categoryId = int.Parse(ViewState["CategoryId"].ToString()); var instituionObj = _db.Categories.FirstOrDefault(m => m.CategoryId == categoryId); instituionObj.Name = txtName.Text; _db.SaveChanges(); ErrorControl1.ShowSuccess("Category Updated successfully"); divForm.Visible = false; divList.Visible = true; LoadCategory(); } catch (Exception ex) { ErrorControl2.ShowError("An error occurred, please contact administrator"); } }