public void GetHashCode_GivenSameValue_ReturnsAsEqual() { var part = new PartNumber("1234567").GetHashCode(); var same = new PartNumber("1234567").GetHashCode(); Assert.Equal(part, same); }
public void GetHashCode_GivenDifferentValue_ReturnsAsEqual() { var part = new PartNumber("1234567").GetHashCode(); var different = new PartNumber("2234567").GetHashCode(); Assert.NotEqual(part, different); }
public void Parse_GivenHyphantedShortPartNumber_ReturnsOkay() { var result = PartNumber.Parse(HyphenatedShortPN); Assert.True(result.IsOkay); Assert.True(result.Contains(new PartNumber(ShortPN))); }
public void Equals_GivenSameValue_ReturnsAsEqual() { var part = new PartNumber("1234567"); var same = new PartNumber("1234567"); Assert.Equal(part, same); }
public void Parse_AlphanumericPartNumber_IsCaseInvariant() { var upper = PartNumber.Parse("1A2345"); var lower = PartNumber.Parse("1a2345"); Assert.Equal(upper, lower); }
public void Parse_RemanPartNumber_IsCaseInvariant() { var upper = PartNumber.Parse("20R1234"); var lower = PartNumber.Parse("20r1234"); Assert.Equal(upper, lower); }
protected void btnPNSubmit_Click(object sender, EventArgs e) { if (lbxManufacturer.SelectedItem == null || lbxProdType.SelectedItem == null || tbNNameSize.Text == string.Empty) { lblMissing.Visible = true; } else { using (var context = new cathlabEntities()) { int cost, par; int.TryParse(tbNCost.Text, out cost); int.TryParse(tbNPar.Text, out par); PartNumber pn = new PartNumber(); pn.PartNum = pnum; pn.NameSize = tbNNameSize.Text; pn.ManufacturerID = int.Parse(lbxManufacturer.SelectedValue); // pn.ProductTypeID = int.Parse(lbxProdType.SelectedValue); // pn.Cost = cost; pn.Par = par; context.PartNumbers.Add(pn); context.SaveChanges(); pnlNewPartNumber.Visible = true; pnlNewPartNumber.Visible = false; lblMissing.Visible = false; autopopulate(); } } }
public void Parse_GivenUntrimmedPartNumber_ReturnsOkay() { var result = PartNumber.Parse(" 1234567 "); Assert.True(result.IsOkay); Assert.True(result.Contains(new PartNumber("1234567"))); }
public JsonResult AddNewEquipmentPart(string name, string description, int?manufacturerId, int?supplierId, int?categoryId, string link, decimal itemsPerUnit, List <string> partNumberValues, List <string> partNumberDescriptions, int equipmentId, int moduleId, double quantityRequired, string unitOfMeasure, string notes) { try { Part p = new Part() { Name = name, Description = description, ManufacturerId = manufacturerId, SupplierId = supplierId, CategoryId = categoryId, ItemsPerUnit = itemsPerUnit }; if (partNumberValues != null && partNumberDescriptions != null) { for (int i = 0; i < partNumberValues.Count; i++) { PartNumber pn = new PartNumber() { Value = partNumberValues[i], Description = partNumberDescriptions[i], Active = true }; p.PartNumbers.Add(pn); } } db.Parts.Add(p); return(AddEquipmentPart(equipmentId, moduleId, p.Id, quantityRequired, unitOfMeasure, notes)); } catch (Exception) { } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); }
//Fake DataBase private List <PartSummary> Context() { var list = new List <PartSummary>(); list.Add(new PartSummary { Description = "Description 1", PartNumber = PartNumber.For("1234-1234abcd") }); list.Add(new PartSummary { Description = "Description 2", PartNumber = PartNumber.For("1235-abcd") }); list.Add(new PartSummary { Description = "Description 3", PartNumber = PartNumber.For("1236-efgh") }); list.Add(new PartSummary { Description = "Description 4", PartNumber = PartNumber.For("1237-1233") } ); return(list); }
private bool CheckData() { if (txtPartNo.Text.Trim() == "") { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Chưa điền dữ liệu"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPartNo.Focus(); return(false); } else if (txtModel.Text.Trim() == "") { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Chưa điền dữ liệu"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtModel.Focus(); return(false); } PartNumber partNumber = _partNumberRepository.FirstOrDefault(_ => _.PartNo.Equals(txtPartNo.Text.Trim())); if (partNumber != null && ( String.IsNullOrEmpty(_id) || (!String.IsNullOrEmpty(_id) && txtPartNo.Text.Trim() != partNumber.PartNo) )) { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Dữ liệu đã tồn tại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPartNo.Focus(); return(false); } return(true); }
public void Parse_GivenPartNumber_ReturnsOkay() { var result = PartNumber.Parse(LongPN); Assert.True(result.IsOkay); Assert.True(result.Contains(new PartNumber(LongPN))); }
public ActionResult DeleteConfirmed(int id) { PartNumber partNumber = db.PartNumbers.Find(id); db.PartNumbers.Remove(partNumber); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool Equals(InventoryItem other) { if (other == null || other.PartNumber == null) { return(false); } return(PartNumber.Equals(other.PartNumber)); }
public override int CompareTo(object y) { if (y is KitDTO) { return(PartNumber.CompareTo(((KitDTO)y).PartNumber)); } return(0); }
public override int CompareTo(object y) { if (y is TemplateKit) { return(PartNumber.CompareTo(((TemplateKit)y).PartNumber)); } return(0); }
public void ToStringReturnsCorrectFormat() { const string value = "1234-1234abcd"; var partNumber = PartNumber.For(value); Assert.AreEqual(value, partNumber.ToString()); }
public override int CompareTo(object y) { if (y is AccessoryRequired) { return(PartNumber.CompareTo(((AccessoryRequired)y).PartNumber)); } return(0); }
public override int GetHashCode() { int detailTypeHash = GoodsClass != null ? GoodsClass.GetHashCode() : -1; int standartHash = Standart != null ? Standart.GetHashCode() : -1; int partNumberHash = PartNumber.GetHashCode(); int descriptionHash = Description.GetHashCode(); return detailTypeHash ^ standartHash ^ partNumberHash ^ descriptionHash; }
public override int GetHashCode() { var componentClassHash = GoodsClass.GetHashCode(); var fullNameHash = FullName.GetHashCode(); var partNumberHash = PartNumber.GetHashCode(); var descriptionHash = Description.GetHashCode(); return(componentClassHash ^ fullNameHash ^ partNumberHash ^ descriptionHash); }
private void GetData() { //Get Data Table PartNumber PartNumber partNumber = _partNumberRepository.Get(_id); txtPartNo.Text = partNumber.PartNo; txtModel.Text = partNumber.Model; txtNote.Text = partNumber.Note; chkUsing.Checked = (partNumber.Status == GlobalConstants.StatusValue.Using); }
public void ImplicitConversionToStringResultsInCorrectString() { const string value = "1234-1234abcd"; var partNumber = PartNumber.For(value); string result = partNumber; Assert.AreEqual(value, result); }
public void ShouldHaveCorrectPartIdAndPartCode() { string value = "1234-1234abcd"; var partNumber = PartNumber.For(value); string result = partNumber; Assert.AreEqual(value, result); }
static void Main(string[] args) { PartNumber p = new PartNumber("BA-0001-3"); for (int i = 0; i < 5; i++) { p.Sub++; Debug.WriteLine(p); } }
public void ParseAll_GivenMultiplePartNumbers_ReturnsAll() { var text = " this part: 1234567, this duplicate part: 1234567, that part: 1A2345, and the other part: 20R3456 are all part numbers"; var partNumbers = PartNumber.ParseAll(text); Assert.Equal(3, partNumbers.Count()); Assert.Contains(new PartNumber("1234567"), partNumbers); Assert.Contains(new PartNumber("1A2345"), partNumbers); Assert.Contains(new PartNumber("20R3456"), partNumbers); }
public ActionResult Edit([Bind(Include = "PKPartNumber,PartNumber1,FKCustomer,Available")] PartNumber partNumber) { if (ModelState.IsValid) { db.Entry(partNumber).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FKCustomer = new SelectList(db.Customers, "PKCustomers", "Customer1", partNumber.FKCustomer); return(View(partNumber)); }
/// <summary> /// Hide properties not appropriate for constituents. /// See also CswNbtObjClassChemical._toggleConstituentProps() /// </summary> private void _toggleConstituentProps() { if( CswEnumTristate.True == IsConstituent.Checked ) { ApprovedForReceiving.setHidden( true, true ); Supplier.setHidden( true, true ); PartNumber.setHidden( true, true ); Receive.setHidden( true, true ); Request.setHidden( true, true ); } } // _toggleConstituentProps()
private void btnSave_Click(object sender, EventArgs e) { try { if (!CheckData()) { return; } //Table PartNumber PartNumber partNumber = new PartNumber(); partNumber.Id = _id; partNumber.PartNo = txtPartNo.Text.Trim(); partNumber.Model = txtModel.Text.Trim(); partNumber.Note = txtNote.Text.Trim(); partNumber.Status = (chkUsing.Checked ? GlobalConstants.StatusValue.Using : GlobalConstants.StatusValue.NoUse); _partNumberRepository.Save(partNumber); UnitOfWork unitOfWork = new UnitOfWork(_projectDataContext); int result = unitOfWork.Complete(); if (result > 0) { if (String.IsNullOrEmpty(_id)) { if (_quickAdd) { this.Tag = txtPartNo.Text.Trim(); DialogResult = DialogResult.OK; Close(); } else { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thành công"), LanguageTranslate.ChangeLanguageText("Thông báo")); Clear(); } } else { DialogResult = DialogResult.OK; Close(); } } else { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
private string ResolveFileName(List <string> dirList, out bool redirectFile) { redirectFile = false; try { if (!IndexSubSys.HasValue) { foreach (string subDir in dirList) { string fileName = Path.Combine(subDir, _fullName.ToLowerInvariant() + FileExtension); if (File.Exists(fileName)) { return(fileName); } fileName = Path.Combine(subDir, _baseName.ToLowerInvariant() + FileExtension); if (File.Exists(fileName)) { return(fileName); } } } if (!string.IsNullOrEmpty(PartNumber) && PartNumber.Length >= 2) { foreach (string subDir in dirList) { string part1 = PartNumber.Substring(0, 2); string part2 = string.Format(CultureInfo.InvariantCulture, "{0:X02}", Address); string baseNameTest = part1 + "-" + part2; if (IndexSubSys.HasValue) { string part3 = string.Format(CultureInfo.InvariantCulture, "{0:X02}", IndexSubSys.Value + 1); baseNameTest += "-" + part3; } string fileName = Path.Combine(subDir, baseNameTest.ToLowerInvariant() + FileExtension); if (File.Exists(fileName)) { redirectFile = true; return(fileName); } } } } catch (Exception) { return(null); } return(null); }
public int GetHashCode(AccessoryRequired other) { if (ReferenceEquals(other, null) == true) { return(0); } int standartHash = Standart != null?Standart.GetHashCode() : -1.GetHashCode(); int partNumberHash = PartNumber.GetHashCode(); int descriptionHash = Description.GetHashCode(); return(standartHash ^ partNumberHash ^ descriptionHash); }