protected void btnSubmit_Click(object sender, EventArgs e) { ProductTypeModel model = new ProductTypeModel(); ProductType pt = CreateProductType(); lblResult.Text = model.InsertProductType(pt); }
protected void btnNewItem_Click(object sender, EventArgs e) { ProductTypeModel model = new ProductTypeModel(); ProductType create = CreateProductType(); LblResult.Text = model.InsertProductType(create); Response.Redirect(Request.RawUrl); }
/// <summary> /// 类别信息 /// </summary> /// <returns></returns> public List <ProductTypeModel> GetProductType() { pbxdatasourceDataContext pddc = new pbxdatasourceDataContext(connectionString); List <ProductTypeModel> list = new List <ProductTypeModel>(); var info = pddc.producttype; ProductTypeModel ptm1 = new ProductTypeModel(); ptm1.TypeName = "请选择"; ptm1.TypeNo = ""; list.Add(ptm1); foreach (var temp in info) { ProductTypeModel ptm = new ProductTypeModel(); ptm.TypeName = temp.TypeName; ptm.TypeNo = temp.TypeNo; list.Add(ptm); } return(list); }
private void FillPage() { var model = new ProductTypeModel(); var productTypes = model.GetAllProductTypes(); if (productTypes.Any()) { foreach (var product in productTypes) { var productPanel = new Panel(); productPanel.CssClass = "ContentPlaceHolder1_pnlProducts"; var imageButton = new ImageButton(); var name = new Label(); imageButton.ImageUrl = "~/Images/ProductTypes/" + product.Image; imageButton.CssClass = "productImage"; imageButton.PostBackUrl = "~/ProductsByType.aspx?id=" + product.ID; name.Text = product.Name; name.CssClass = "productName"; productPanel.Controls.Add(imageButton); productPanel.Controls.Add(new Literal { Text = "<br />" }); productPanel.Controls.Add(name); productPanel.Controls.Add(new Literal { Text = "<br />" }); pnlProducts.Controls.Add(productPanel); } } else { pnlProducts.Controls.Add(new Literal { Text = "No product types found" }); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProductTypeModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update ProductType set "); strSql.Append(" ParentProductTypeId = @ParentProductTypeId , "); strSql.Append(" ProductTypeName = @ProductTypeName , "); strSql.Append(" Memo = @Memo , "); strSql.Append(" OrderNo = @OrderNo "); strSql.Append(" where ProductTypeId=@ProductTypeId "); SqlParameter[] parameters = { new SqlParameter("@ProductTypeId", SqlDbType.Decimal, 9), new SqlParameter("@ParentProductTypeId", SqlDbType.Decimal, 9), new SqlParameter("@ProductTypeName", SqlDbType.VarChar, 50), new SqlParameter("@Memo", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.ProductTypeId; parameters[1].Value = model.ParentProductTypeId; parameters[2].Value = model.ProductTypeName; parameters[3].Value = model.Memo; parameters[4].Value = model.OrderNo; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
private void textBox1_TextChanged(object sender, EventArgs e) { string name = textBox1.Text; ProductsModel pm = new ProductsModel(); pm.ProductJP1 = name; for (int i = 0; i < tv.Nodes.Count; i++) { if (tv.Nodes[i].Name.Contains(name)) { tv.Nodes[i].ImageIndex = 1; } } if (tabControl1.TabPages[0].Text == "项目清单") { DataTable dt = ConsumerBillBLL.getTableSS(pm); dataGridView1.DataSource = dt; } if (tabControl1.TabPages[1].Text == "项目列表") { tv.Nodes.Clear(); //列表 DataTable dt2 = ConsumerBillBLL.getTableLB(); for (int i = 0; i < dt2.Rows.Count; i++) { TreeNode root = new TreeNode(dt2.Rows[i]["PTName"].ToString()); root.Name = dt2.Rows[i]["PTName"].ToString(); root.ImageIndex = 1; tv.Nodes.Add(root); ProductTypeModel ptype = new ProductTypeModel(); ptype.PTName1 = dt2.Rows[i]["PTName"].ToString(); DataTable dt3 = ConsumerBillBLL.getTableSSLB(ptype, pm); for (int j = 0; j < dt3.Rows.Count; j++) { TreeNode node = new TreeNode(dt3.Rows[j]["项目名称"].ToString()); node.Name = dt3.Rows[j]["项目名称"].ToString(); root.Nodes.Add(node); } } //tabPage2.Controls.Add(tv2); } }
private void btnSave_Click(object sender, EventArgs e) { var model = new ProductTypeModel(); model.PRODUCT_TYPE_NAME = txtPRODUCT_TYPE_NAME.Text; int.TryParse(txtID.Text, out int id); model.ID = id; if (model.Validate() == false) { MessageBox.Show(this, "All values are required", "Save Action failed !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } model.Save(); txtID.Text = model.ID.ToString(); txtPRODUCT_TYPE_NAME.Focus(); txtPRODUCT_TYPE_NAME.Select(); }
public async Task <ActionResult <ProductType> > PostProductType(ProductTypeModel productTypeModel) { var result = new Result <ProductType>(); ProductType productType = new ProductType(); _mapper.Map(productTypeModel, productType); try { result.Data = productType; await _context.ProductType.AddAsync(productType); await _context.SaveChangesAsync(); } catch (Exception e) { result.ErrorMessage = e.Message; result.IsFound = false; } return(Ok(result)); }
private void btnSave_Click(object sender, EventArgs e) { try { if (!checkValid()) { return; } ProductTypeModel dModel; if (_isAdd) { dModel = new ProductTypeModel(); } else { int ID = Convert.ToInt32(grvData.GetFocusedRowCellValue("ID")); dModel = (ProductTypeModel)ProductTypeBO.Instance.FindByPK(ID); } dModel.ProductTypeCode = txtCode.Text.Trim(); dModel.ProductTypeName = txtName.Text.Trim(); if (_isAdd) { ProductTypeBO.Instance.Insert(dModel); } else { ProductTypeBO.Instance.Update(dModel); } loadData(); setInterface(false); clearInterface(); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult SaveType([Bind(Include = "UniqueId, Name, Description, ValidFrom, ValidTo")] ProductTypeModel p) { if (!ModelState.IsValid) { return(View("CreateType", p)); } var type = ProductTypes.Instance.Find(x => x.IsThisUniqueId(p.UniqueId)); if (type == null) { return(HttpNotFound()); } type.Name = p.Name; type.Description = p.Description; type.Valid.From = p.ValidFrom; type.Valid.To = p.ValidTo; var ebl = new EntryBusinessLayer(); ebl.UploadTypes(ProductTypes.Instance.ToList()); return(EntryDetails(type.CatalogueEntryId)); }
private void InitUI() { //初始化TextEdit TextEdit[] edits = { this.textEdit2, this.textEdit4 }; InitTextEdit(edits); //首先要获取产品列表数组 this.productTypes = SysManage.ProductTypes; // 设置 comboBox的文本值不能被编辑 this.comboBoxEdit1.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; this.comboBoxEdit1.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; //初始化ComboBoxEdit for (int i = 0; i < productTypes.Count(); i++) { ProductTypeModel item = this.productTypes[i]; this.comboBoxEdit1.Properties.Items.Add(item.typeName); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ProductTypeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProductType("); strSql.Append("ParentProductTypeId,ProductTypeName,Memo,OrderNo"); strSql.Append(") values ("); strSql.Append("@ParentProductTypeId,@ProductTypeName,@Memo,@OrderNo"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ParentProductTypeId", SqlDbType.Decimal, 9), new SqlParameter("@ProductTypeName", SqlDbType.VarChar, 50), new SqlParameter("@Memo", SqlDbType.VarChar, 50), new SqlParameter("@OrderNo", SqlDbType.Int, 4) }; parameters[0].Value = model.ParentProductTypeId; parameters[1].Value = model.ProductTypeName; parameters[2].Value = model.Memo; parameters[3].Value = model.OrderNo; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
private void btnOK_Click(object sender, EventArgs e) { if (ptype.PTID1 == -1) { //新增 string name = txtType.Text.Trim(); ProductTypeModel ptype2 = new ProductTypeModel(); ptype2.PTName1 = name; int result = ProductsBLL.getAddType(ptype2); if (result > 0) { MessageBox.Show("OK"); this.Close(); GoodsForm gf = new GoodsForm(); gf.Show(); } else { MessageBox.Show("NO"); } } else { //修改 string name = txtType.Text.Trim(); ProductTypeModel ptype2 = new ProductTypeModel(ptype.PTID1, name); int result = ProductsBLL.getUpdateType(ptype2); if (result > 0) { MessageBox.Show("OK"); this.Close(); GoodsForm gf = new GoodsForm(); gf.Show(); } else { MessageBox.Show("NO"); } } }
public ActionResult GetModel(int id, string culture) { var productType = _repository.Find(id); var compared = Mapper.Map <ProductType, ProductTypeModel>(productType); var translated = new ProductTypeModel { Id = compared.Id, Name = compared.Name }; // Difference of compared product type and the previous compared product type var diff = new ProductTypeModel { Id = compared.Id, Name = compared.Name }; var entityKey = EntityKey.FromEntity(productType); var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), entityKey); foreach (var field in compared.CustomFieldDefinitions) { translated.CustomFieldDefinitions.Add(LoadFieldTranslation(field, "CustomFieldDefinitions", translation)); diff.CustomFieldDefinitions.Add(LoadFieldDiff(field, "CustomFieldDefinitions", translation)); } foreach (var field in compared.VariantFieldDefinitions) { translated.VariantFieldDefinitions.Add(LoadFieldTranslation(field, "VariantFieldDefinitions", translation)); diff.VariantFieldDefinitions.Add(LoadFieldDiff(field, "VariantFieldDefinitions", translation)); } return(Json(new { Compared = compared, Difference = diff, Translated = translated }, JsonRequestBehavior.AllowGet)); }
public ActionResult Translate(int id, string culture, ProductTypeModel model, string @return) { var entityKey = new EntityKey(typeof(ProductType), id); var productType = _repository.Find(model.Id); var props = new List <PropertyTranslation>(); foreach (var field in model.CustomFieldDefinitions) { var originalField = productType.CustomFieldDefinitions.Find(field.Id); UpdateFieldTranslation(originalField, field, "CustomFieldDefinitions[" + field.Name + "].", props); } foreach (var field in model.VariantFieldDefinitions) { var originalField = productType.VariantFieldDefinitions.Find(field.Id); UpdateFieldTranslation(originalField, field, "VariantFieldDefinitions[" + field.Name + "].", props); } _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), entityKey, props); return(AjaxForm().RedirectTo(@return)); }
private void btnDeleteType_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("确定删除该行数据?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { int index = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value); ProductTypeModel ptype = new ProductTypeModel(); ptype.PTID1 = index; int result = ProductsBLL.getDeleteType(ptype); if (result > 0) { MessageBox.Show("OK"); cmdType.Items.Clear(); GoodsForm_Load(null, null); } else { MessageBox.Show("NO"); } } }
//add function to the submit button protected void submitButton_Click(object sender, EventArgs e) { //get the ProductTypeModel.cs function ProductTypeModel ptModel = new ProductTypeModel(); //call the createProductType() method ProductType productType = createProductType(); //add new ProductType if (String.IsNullOrWhiteSpace(Request.QueryString["id"])) { //display the resultmessage and call the InSetProductType method from pm which is the productModle.cs TextBoxProductDesc.Text = ptModel.InSetProductType(productType); } //modify existing model update else { //get the existing ProductType id int id = Convert.ToInt32(Request.QueryString["id"]); //use update method TextBoxProductDesc.Text = ptModel.UpdateProductType(id, productType); } }
public ActionResult GetTranslations(string type) { using (var unit = GetUnitOfWork()) { var repo = new ProductTypeRepository(unit, _defaultVendorID); var types = unit.Service <Product>().GetAll(c => _vendorIDs.Any(x => x == c.SourceVendorID) && c.IsConfigurable).Select(c => c.VendorItemNumber).ToList().Select(c => c.Split(new char[] { '-' }).Try(l => l[1], string.Empty)).Distinct().ToList();//.Substring(5, 3)).ToList(); var filledIn = repo.GetAll().Where(c => c.Type != null); var existingType = types.FirstOrDefault(x => x == type); if (existingType == null && !string.IsNullOrEmpty(type)) { return(Failure("Type does not exist or type is null or empty")); } var record = filledIn.FirstOrDefault(x => x.Type == existingType); if (record == null) { record = new ProductTypeModel(); } if (record.Translations == null) { record.Translations = new Dictionary <int, string>(); } return(List(u => (from l in unit.Service <Language>().GetAll().ToList() join p in record.Translations on l.LanguageID equals p.Key into temp from tr in temp.DefaultIfEmpty() select new { l.LanguageID, Language = l.Name, Name = tr.Value, @Type = type }).AsQueryable())); } }
public async Task <ActionResult> Create(ProductTypeModel model) { string key = autoKey(); try { if (ModelState.IsValid) { var type = new Ref_Product_TypesDTO(); if (key != null) { type.product_type_code = key; } else { type.product_type_code = model.product_type_code; } type.product_type_description = model.description; HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url + "/ProductTypes", type); if (responseMessage.IsSuccessStatusCode) { //var responseData = responseMessage.Content.ReadAsStringAsync().Result; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; } return(RedirectToAction("Index")); } } catch (Exception) { ModelState.AddModelError("", "Error"); } return(View(model)); }
public ActionResult addProduct() { Database db; int typeID = Int32.Parse(Request.Params["protype_id"]); string[] brandID = Request.Form.GetValues("probrand_id"); ProductTypeModel ptModel = new ProductTypeModel(); ptModel.PRO_TYP_ID = typeID; for (int i = 0; i < brandID.Length; i++) { ProductBrandModel pbModel = new ProductBrandModel(); pbModel.PRO_BRAND_ID = Int32.Parse(brandID[i]); ProductModel pModel = new ProductModel(); pModel.BANRD = pbModel; pModel.TYPE = ptModel; // ค้นข้อมูลมา ตรวจสอบค่าก่อนจะเพิ่มลงฐานข้อมูล db = new Database(); ProductDAO pDAO = new ProductDAO(db); bool tf = pDAO.HasField(pModel); // ค้นหาจาก Type and brand db.Close(); // ถ้าไม่มีให้เพิ่มได้ ถ้ามีไม่ต้องทำอะไร if (!tf) { db = new Database(); pDAO = new ProductDAO(db); pDAO.Add(pModel); db.Close(); } } return(RedirectToAction("ManageProduct", "Product")); }
private void InitUI() { //初始化ComboBoxEdit DevExpress.XtraEditors.ComboBoxEdit[] edits = { this.comboBoxEdit1, }; SetupCombox(edits, false); //首先要获取产品列表数组 this.productTypes = SysManage.ProductTypes; this.comboBoxEdit1.Properties.Items.Add("无"); //初始化ComboBoxEdit for (int i = 0; i < productTypes.Count(); i++) { ProductTypeModel item = productTypes[i]; this.comboBoxEdit1.Properties.Items.Add(item.typeName); } // 设置 comboBox的文本值不能被编辑 ToolsManage.SetGridView(this.gridView1, GridControlType.ProductManage, out this.mainDataTable, ColumnButtonClick, null); this.gridControl1.DataSource = this.mainDataTable; }
public async Task <IActionResult> PutProductType(int id, ProductTypeModel productTypeModel) { var result = new Result <string>(); Type typeType = typeof(ProductType); var updateType = await _context.Cart.Where(x => x.CartId == id).FirstOrDefaultAsync(); if (updateType == null) { return(NotFound(DataNotFound(result))); } UpdateTable(productTypeModel, typeType, updateType); try { await _context.SaveChangesAsync(); } catch (Exception e) { result.ErrorMessage = e.Message; result.IsSuccess = false; return(BadRequest(result)); } return(Ok(result)); }
public virtual IActionResult EditProductType(int id) { var producttype = _producttypeService.GetProductTypeById(id); if (producttype == null || producttype.Deleted) { //No producttype found with the specified id return(RedirectToAction("ListProductType")); } //var model = new ProductTypeModel(); var model = new ProductTypeModel { ProductTypeName = producttype.ProductTypeName, PunchLine = producttype.PunchLine, Description = producttype.Description, ProductTypeImage = producttype.ProductTypeImage, Status = producttype.Status, }; return(View(model)); }
private void loadData2DatagridView() { dgvProduct.Rows.Clear(); dgvProduct.Refresh(); productTypeNameList.Clear(); if (busProduct.convertDatatable2Dict().Count > 0) { this.statusLabel.Visible = false; foreach (KeyValuePair <string, ProductsModel> product in busProduct.convertDatatable2Dict()) { ProductTypeModel productType = busProductType.convertDatatable2Dict()[product.Value.productTypeId]; dgvProduct.Rows.Add(product.Key, product.Value.productName, productType.productTypeName); productTypeNameList.Add(productType.productTypeName); } setDataDetail(0); } else { this.statusLabel.Visible = true; setDataDetailNull(); } }
public ActionResult AddProductType() { string proTypeName = Request.Params["protype_name"].Trim(); ProductTypeModel ptModel = new ProductTypeModel(); ptModel.PRO_TYPE_NAME = proTypeName; Database db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); int id = ptDAO.Add(ptModel); db.Close(); System.Diagnostics.Debug.WriteLine("LAST ID PRODUCT_TYPE : " + id); if (id > 0) { return(RedirectToAction("Alert", "Product", new { link = "~/Product/ManageProduct", massage = "เพิ่มข้อมูลเรียบร้อย" })); } else { return(RedirectToAction("ManageProduct", "Product")); } }
public async Task <bool> DeleteProductType(ProductTypeModel type) { bool result = false; try { using (var db = dbManager.GetConnection()) using (var command = db.Connection.CreateCommand()) { command.CommandText = string.Format("DELETE FROM PRODUCTTYPE WHERE Id = {0}", type.TypeId); await command.ExecuteNonQueryAsync().ConfigureAwait(false); result = true; } } catch (Exception ex) { result = false; logger.Error("Exception during execution method \"DeleteProductType\": {0}", ex.Message); } return(result); }
public List <ProductTypeModel> GetProductTypes() { List <ProductTypeModel> _productTypeModelList = null; var productTypeList = _unitOfWork.productTypeRepository.GetAll().ToList(); if (productTypeList == null) { return(_productTypeModelList); } _productTypeModelList = new List <ProductTypeModel>(); //-- Go through each record from table foreach (var _productType in productTypeList) { //--Create single Product Type Model and add it to View model ProductTypeModel productTypeModelSingle = new ProductTypeModel(); foreach (var propDest in productTypeModelSingle.GetType().GetProperties()) { //Find property in source based on destination name var propSrc = _productType.GetType().GetProperty(propDest.Name); if (propSrc != null) { //Get value from source and assign it to destination propDest.SetValue(productTypeModelSingle, propSrc.GetValue(_productType)); } } _productTypeModelList.Add(productTypeModelSingle); } //--Below code insert first element as [None]--- //ProductTypeModel noneElement = new ProductTypeModel(); //noneElement.Id = 0; //noneElement.StoreID = 0; //noneElement.Description = "[None]"; //_productTypeModelList.Insert(0, noneElement); return(_productTypeModelList); }
public async Task <long> SaveProductType(ProductTypeModel productType) { long typeId = productType.TypeId; try { using (var db = dbManager.GetConnection()) using (var command = db.Connection.CreateCommand()) { if (typeId == 0) { //is this part really needed? command.CommandText = string.Format("SELECT TypeId FROM PRODUCTTYPE WHERE Name='{0}'", productType.Name); typeId = (long)(await command.ExecuteScalarAsync().ConfigureAwait(false) ?? 0L); } if (typeId == 0) { command.CommandText = string.Format("INSERT INTO PRODUCTTYPE (Name) VALUES ('{0}'); SELECT last_insert_rowid() FROM PRODUCTTYPE", productType.Name); typeId = (long)(await command.ExecuteScalarAsync().ConfigureAwait(false)); logger.Debug("Saving new product type with name={0} and id={1}", productType.Name, typeId); } else { command.CommandText = string.Format("UPDATE PRODUCTTYPE SET Name = '{0}' WHERE TypeId = {1}", productType.Name, productType.TypeId); await command.ExecuteNonQueryAsync().ConfigureAwait(false); logger.Debug("Updating existed product type with name={0} and id={1}", productType.Name, typeId); } } } catch (Exception ex) { typeId = -1; logger.Error("Exception during execution method \"SaveProductType\": {0}", ex.Message); } return(typeId); }
public int UpdateProductType(ProductTypeModel productTypeModel) { int result = 0; try { using (var context = new BhasadEntities()) { var productType = context.ProductTypes.SingleOrDefault(m => m.ProductTypeId == productTypeModel.ProductTypeId); if (productType != null) { productType.ProductTypeName = productTypeModel.ProductType; productType.ModifiedBy = 1; productType.ModifiedDate = DateTime.Now; } result = context.SaveChanges(); } } catch (Exception ex) { throw ex; } return(result); }
public ActionResult CreateType( [Bind(Include = "UniqueId,Name,Description,ValidFrom,ValidTo,CatalogueEntryId")] ProductTypeModel p) { if (!ModelState.IsValid) { return(View("CreateType", p)); } var type = new ProductType() { UniqueId = Guid.NewGuid().ToString(), Name = p.Name, Description = p.Description, CatalogueEntryId = p.CatalogueEntryId, Valid = new Period() { From = p.ValidFrom, To = p.ValidTo } }; var ebl = new EntryBusinessLayer(); ProductTypes.Instance.Add(type); ebl.UploadTypes(ProductTypes.Instance.ToList()); return(EntryDetails(type.CatalogueEntryId)); }
public ActionResult Save(ProductTypeModel model, string @return) { ProductType productType = null; if (model.Id == 0) { productType = _productTypeService.Create(new CreateProductTypeRequest { Name = model.Name, SkuAlias = model.SkuAlias, CustomFields = model.CustomFieldDefinitions, VariantFields = model.VariantFieldDefinitions }); } else { productType = _productTypeService.Update(new UpdateProductTypeRequest(model.Id) { Name = model.Name, SkuAlias = model.SkuAlias, CustomFields = model.CustomFieldDefinitions, VariantFields = model.VariantFieldDefinitions }); } if (model.IsEnabled) { _productTypeService.Enable(productType); } else { _productTypeService.Disable(productType); } return(AjaxForm().RedirectTo(@return)); }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { try { ProductTypeModel model = new ProductTypeModel(); ProductType newProductType = CreateProductType(TextBoxName.Text); LabelResult.Text = model.AddProductType(newProductType); LabelResult.ForeColor = System.Drawing.Color.Green; TextBoxName.Text = string.Empty; } catch (Exception ex) { LabelResult.Text = ex.StackTrace + "\n" + ex.Message; LabelResult.ForeColor = System.Drawing.Color.Red; } } else { LabelResult.Text = "The input is not valid"; } }
public ActionResult Edit(ProductTypeModel request) { if (ModelState.IsValid) { try { var model = db.ProductTypes.Find(request.Id); Binder.Bind(request, ref model); db.SaveChanges(); return(RedirectToAction("List")); } catch (Exception exc) { Console.WriteLine(exc); } } InitFilds(); return(PartialView(request)); }
public async void ProductTypeUpdate() { // Arrange this.QuarryDbContext.ProductTypes.AddRange( new ProductTypeEntity() { ProductTypeId = 1, ProductTypeName = "Slab", CompanyId = 1, DeletedInd = false }, new ProductTypeEntity() { ProductTypeId = 2, ProductTypeName = "Tile", CompanyId = 1, DeletedInd = false }); await this.SaveChangesAsync(this.QuarryDbContext); ProductTypeModel model = new ProductTypeModel() { ProductTypeId = 2, ProductTypeName = "Boulder" }; // Act AjaxModel<NTModel> ajaxModel = await this.Controller.ProductTypeUpdate(model); // Assert ProductTypeEntity entity = this.QuarryDbContext.ProductTypes.Where(e => e.ProductTypeId == 2).First(); Assert.Equal(entity.ProductTypeName, "Boulder"); Assert.Equal(ajaxModel.Message, QuarryMessages.ProductTypeSaveSuccess); }
//FillPage() method private void FillPage(int id) { ProductTypeModel ptModel = new ProductTypeModel(); ProductType productType = ptModel.GetProduct(id); TextBoxProductDesc.Text = productType.TypeDescreption; }
public async void ProductTypeAdd() { // Arrange ProductTypeModel model = new ProductTypeModel() { ProductTypeId = 0, ProductTypeName = "Tile" }; // Act AjaxModel<NTModel> ajaxModel = await this.Controller.ProductTypeAdd(model); // Assert ProductTypeEntity entity = this.QuarryDbContext.ProductTypes.Last(); Assert.Equal(entity.ProductTypeName, "Tile"); Assert.Equal(ajaxModel.Message, QuarryMessages.ProductTypeSaveSuccess); }