public int Insert(PartCategory partcategory_) { try { var partcategorytoinsert = new PartCategory { CategoryID = partcategory_.CategoryID, CategoryName = partcategory_.CategoryName, CategoryNameES = partcategory_.CategoryNameES, CategoryNameCN = partcategory_.CategoryNameCN, CategoryDescription = partcategory_.CategoryDescription, CategoryDescriptionES = partcategory_.CategoryDescriptionES, CategoryDescriptionCN = partcategory_.CategoryDescriptionCN, IsActive = true, Notes = partcategory_.Notes, LastEditedBy = partcategory_.LastEditedBy, LastEditDate = partcategory_.LastEditDate, CreateDate = partcategory_.CreateDate, CreatedBy = partcategory_.CreatedBy }; _qualityEntities.AddToPartCategories(partcategorytoinsert); _qualityEntities.SaveChanges(SaveOptions.None); return(partcategorytoinsert.CategoryID); } catch (Exception ex) { string errormessage = ex.ToString(); return(0); } }
public async Task <ActionResult <PartCategory> > PostPartCategory(PartCategory partCategory) { _context.PartCategories.Add(partCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPartCategory", new { id = partCategory.CategoryID }, partCategory)); }
async Task <string> IRepository <PartCategory> .AddAsync(PartCategory item) { item.Id = ObjectId.GenerateNewId().ToString(); await this._bundle.PartCategorytRepository.Collection.InsertOneAsync(item); return(item.Id); }
public string PartTypeName(int typeID) { PartTypes pt = _context.PartTypes.Where(r => r.PartTypeID == typeID).FirstOrDefault(); PartCategory ct = _context.PartCategory.Where(c => c.PartCategoryID == pt.PartCategoryID).FirstOrDefault(); return($"{ct.PartCategoryName.Trim()} - {pt.PartTypeName.Trim()}"); }
protected void btnSave_Click(object sender, EventArgs e) { //save new PartCategory PartCategory model = new PartCategory(); model.CategoryName = this.txtCategoryName.Text.Trim(); model.Description = this.txtDescription.Text.Trim(); if (this.hidCategoryID.Value.Length > 0) { model.CategoryID = int.Parse(this.hidCategoryID.Value); Service.UpdatePartCategory(model); } else { PartCategory temp = new PartCategory(); temp.CategoryName = model.CategoryName; List <PartCategory> list = Service.QueryPartCategorys(temp); if (list != null && list.Count > 0) { RegisterStartupScript("Message", "<script>alert('该物料类别名称已存在');</script>"); return; } else { model = Service.AddPartCategory(model); this.hidCategoryID.Value = model.CategoryID.ToString(); //this.RegisterStartupScript("back", "<script>window.location.href='PartCategoryList.aspx';</script>"); } } ScriptManager.RegisterStartupScript(this, this.GetType(), "closeScript", "closeDialogOnSave();", true); }
public async Task <IActionResult> PutPartCategory([FromRoute] int id, [FromBody] PartCategory partCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != partCategory.Id) { return(BadRequest()); } _context.Entry(partCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PartCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected void ReadXmlUsingXMLDocument_Click(object sender, EventArgs e) { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("XML/19461.xml")); //Display all the Activities alone in the XML XmlNodeList elemList = doc.GetElementsByTagName("branchItem"); int count = 0; PartCategory[] PartsList = new PartCategory[elemList.Count]; foreach (XmlNode xn in elemList) { PartsList[count] = new PartCategory(); PartsList[count].Id = xn["id"].InnerText; PartsList[count].SeoSlug = xn["seoslug"].InnerText; PartsList[count].Type = xn["type"].InnerText; PartsList[count].Name = xn["name"].InnerText; PartsList[count].ImageS = xn["imageS"].InnerText; count++; } foreach (PartCategory pc in PartsList) { doc.Load(Server.MapPath("XML/" + pc.Id + ".xml")); XmlNodeList subElemList = doc.GetElementsByTagName("branchCategory"); pc.SeoSlug = subElemList[0]["seoslug"].InnerText; } }
public ActionResult DeleteConfirmed(int id) { PartCategory partCategory = db.PartCategories.Find(id); db.PartCategories.Remove(partCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
private void partCategorykryptonComboBox5_SelectedIndexChanged(object sender, EventArgs e) { partCategorykryptonTextBox.Text = ""; if (partCategorykryptonComboBox5.SelectedItem != null) { PartCategory p = (PartCategory)partCategorykryptonComboBox5.SelectedItem; partCategorykryptonTextBox.Text = p.NAME; } }
public void PostNewPartCategoryToDB(CategoryInsertViewModel partCategory) { var partCategoryToInsert = new PartCategory(); partCategoryToInsert.CategoryPart = partCategory.CategoryPart; _partCategoryContext.Insert(partCategoryToInsert); _partCategoryContext.Commit(); _logger.Info("Inserted record Id " + partCategoryToInsert.Id + " into Table " + tableNameUsedByLogger); }
private void bindGridView() { PartCategory filter = new PartCategory(); List <PartCategory> objs = Service.QueryPartCategorys(filter); this.GridView1.DataSource = objs; this.GridView1.DataBind(); }
public Part(string name, double buyPrice, double sellPrice, Manufacturer manufacturer, string code, PartCategory category) { this.name = name; this.buyPrice = buyPrice; this.sellPrice = sellPrice; this.manufacturer = manufacturer; this.code = code; this.category = category; this.supportedCars = new HashSet <Car>(); }
public ActionResult Edit([Bind(Include = "Id,PartCategoryDesc")] PartCategory partCategory) { if (ModelState.IsValid) { db.Entry(partCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(partCategory)); }
private void bindBaseData(string categoryID) { PartCategory model = Service.GetPartCategoryByKey(new PartCategory { CategoryID = int.Parse(categoryID) }); //bind PartCategory infomation this.hidCategoryID.Value = model.CategoryID.ToString(); this.txtCategoryName.Text = model.CategoryName; this.txtDescription.Text = model.Description; }
/// <summary> /// Find Parts from PartList's partPacks. /// </summary> /// <param name="partCategory">Desired PartCategory</param> /// <returns>Returns all Parts of a given PartCategory.</returns> public List <Part> FindParts(PartCategory partCategory) { foreach (PartPack p in this.partPacks) { if (p.category == partCategory) { return(p.parts); } } return(new List <Part>()); }
public Part (string name, double buyPrice, double sellPrice, Manufacturer manufacturer, string code, PartCategory category) { this.name = name; this.buyPrice = buyPrice; this.sellPrice = sellPrice; this.manufacturer = manufacturer; this.code = code; this.category = category; this.supportedCars = new HashSet<Car>(); }
public static PartPack GetPack(PartCategory category, List <PartPack> pack) { foreach (PartPack p in pack) { if (p.category == category) { return(p); } } return(null); }
public ActionResult Create([Bind(Include = "Id,PartCategoryDesc")] PartCategory partCategory) { if (ModelState.IsValid) { db.PartCategories.Add(partCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(partCategory)); }
public async Task <IActionResult> PostPartCategory([FromBody] PartCategory partCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PartCategory.Add(partCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPartCategory", new { id = partCategory.Id }, partCategory)); }
private void updateRecord() { foreach (DataGridViewRow item in gridData.Rows) { PartCategory dep = (PartCategory)item.Tag; if (dep.ID == m_prtCat.ID) { gridData[0, item.Index].Value = m_prtCat.CODE; gridData[1, item.Index].Value = m_prtCat.NAME; break; } } }
private void removeRecord(int id) { foreach (DataGridViewRow item in gridData.Rows) { PartCategory dep = (PartCategory)item.Tag; if (dep.ID == id) { gridData.Rows.Remove(item); break; } } gridData.ClearSelection(); }
// GET: PartCategories/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PartCategory partCategory = db.PartCategories.Find(id); if (partCategory == null) { return(HttpNotFound()); } return(View(partCategory)); }
public void ClearForm() { try { textBoxCode.Text = ""; textBoxName.Text = ""; m_prtCat = new PartCategory(); errorProvider1.Clear(); } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private string getDirectoryName(PartCategory partCategory) { switch (partCategory) { case PartCategory.FacialHair: return("Facial Hair"); case PartCategory.SkinDetails: return("Skin Details"); default: return("" + partCategory); } }
protected void butDelete_Click(object sender, EventArgs e) { for (int i = 0; i <= this.GridView1.Rows.Count - 1; i++) { GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("ChkSelected")).Checked; if (isChecked) { string sid = GridView1.DataKeys[row.RowIndex]["CategoryID"].ToString(); PartCategory obj = new PartCategory(); obj.CategoryID = int.Parse(sid); Service.DeletePartCategory(obj); } } bindGridView(); }
private void gridData_SelectionChanged(object sender, EventArgs e) { if (gridData.SelectedRows.Count == 0) { return; } ClearForm(); m_prtCat = (PartCategory)gridData.SelectedRows[0].Tag; if (m_prtCat == null) { return; } loadData(); setEnableForm(false); setEditMode(EditMode.View); }
public static string GetDirectoryName(PartCategory partCategory) { switch (partCategory) { case PartCategory.FacialHair: return("Facial Hair"); case PartCategory.SkinDetails: return("Skin Details"); case PartCategory.BodySkin: return("Body Skin"); default: return("" + partCategory); } }
public void Update(PartCategory PartCategory_) { var categorytoupdate = _qualityEntities.PartCategories .FirstOrDefault(x => x.CategoryID == PartCategory_.CategoryID); categorytoupdate.CategoryName = PartCategory_.CategoryName; categorytoupdate.CategoryNameES = PartCategory_.CategoryNameES; categorytoupdate.CategoryNameCN = PartCategory_.CategoryNameCN; categorytoupdate.CategoryDescription = PartCategory_.CategoryDescription; categorytoupdate.CategoryDescriptionCN = PartCategory_.CategoryDescriptionCN; categorytoupdate.CategoryDescriptionES = PartCategory_.CategoryDescriptionES; categorytoupdate.IsActive = PartCategory_.IsActive; categorytoupdate.Notes = PartCategory_.Notes; categorytoupdate.LastEditDate = PartCategory_.LastEditDate; categorytoupdate.LastEditedBy = PartCategory_.LastEditedBy; _qualityEntities.SaveChanges(SaveOptions.None); }
void Start() { Logging.DebugLog("Start Start"); Instance = this; InvokeRepeating("VerifyEditor", Settings.CurrentSaveSettings.RefreshTime / 10f, Settings.CurrentSaveSettings.RefreshTime / 10f); //load settings Settings.LoadSettings(); EventListeners.Instance.RegisterListeners(); if (HighLogic.LoadedSceneIsEditor) { PartCategory.CreateInventoryPartCategory(); EditorVerificationRequired = true; } ScrapYardEvents.OnSYReady.Fire(); Logging.DebugLog("Start Complete"); }
public ActionResult Save(PartCategory category) { if (!ModelState.IsValid) { return(View("PartCategoryForm", category)); } if (category.Id == 0) { _context.PartCategories.Add(category); } else { var categoryInDb = _context.PartCategories.SingleOrDefault(c => c.Id == category.Id); TryUpdateModel(categoryInDb); } _context.SaveChanges(); return(RedirectToAction("Index")); }
public void SetUp() { var catA = new PartCategory { Category = "Cat A" }; var catB = new PartCategory { Category = "Cat B" }; this.PartCategoriesService.GetCategories() .Returns(new SuccessResult <IEnumerable <PartCategory> >(new List <PartCategory> { catA, catB })); this.Response = this.Browser.Get( "/inventory/part-categories", with => { with.Header("Accept", "application/json"); }).Result; }
public IList<Part> DisplayPartsByCategory(Product product, PartCategory category) { return product.Parts.Where(p => p.Category.Id == category.Id).ToList(); }