private void LoadBom() { //var farmCtrl = new FarmController(); var coll = BomController.GetAllBoms(TxtFilter.Text); gv.DataSource = coll; //LoadItem(""); }
private void SaveBom() { try { if (dtBomItem.Rows.Count == 0) { throw new Exception("กรุณาเลือกสินค้าย่อย"); } var bomItems = new List <BomItem>(); int seq = 0; foreach (DataRow row in dtBomItem.Rows) { seq++; bomItems.Add(new BomItem { BomCode = String.IsNullOrEmpty(txtBomCode.Text) == true ? 0 : Convert.ToInt32(txtBomCode.Text), Product = new Product { ProductCode = row[ConstColumns.PRODUCT_CODE].ToString(), ProductName = row[ConstColumns.PRODUCT_NAME].ToString(), }, MutiplyQty = 1, MutiplyWgh = 1, //MutiplyQty = row[ConstColumns.ISSUE_UNIT_METHOD].ToString() == "Q" ? Convert.ToInt16(row[ConstColumns.QTY_WGH]) : 0, //MutiplyWgh = row[ConstColumns.ISSUE_UNIT_METHOD].ToString() == "W" ? Convert.ToDecimal(row[ConstColumns.QTY_WGH]) : 0, }); } var bom = new Bom { BomCode = string.IsNullOrEmpty(txtBomCode.Text) == true ? 0 : Convert.ToInt32(txtBomCode.Text), Product = new Product { ProductCode = this.productCode, ProductName = txtProductName.Text, }, Active = chkActive.Checked, CreateBy = "system", ModifiedBy = "system", BomItems = bomItems }; if (string.IsNullOrEmpty(txtBomCode.Text)) { BomController.Insert(bom); } else { BomController.Update(bom); } } catch (Exception) { throw; } }
static void Main(string[] args) { BomController ctrl = new BomController(); BomEntry[] entries = ctrl.ReadBomFile(); string manufacturer = ctrl.GetManufacturer(entries); ctrl.WriteOrder(entries, manufacturer); }
public void ReadBomFile_Call_ShouldReturn19Entries() { // Arrange BomController ctrl = new BomController(); // Act BomEntry[] entries = ctrl.ReadBomFile(); // Assert Assert.IsNotNull(entries); Assert.AreEqual(15, entries.Length); }
public void GetOrdersForManufacturer_CallForInvalidManufacturer_ShouldNotReturnAnyEntries() { // Arrange BomController ctrl = new BomController(); BomEntry[] entries = ctrl.ReadBomFile(); // Act BomEntry[] entriesForXxx = ctrl.GetOrdersForManufacturer(entries, "XXX"); // Assert Assert.IsNotNull(entriesForXxx); Assert.AreEqual(0, entriesForXxx.Length); }
public void GetOrdersForManufacturer_CallForPanasonic_ShouldReturnTwoEntries() { // Arrange BomController ctrl = new BomController(); BomEntry[] entries = ctrl.ReadBomFile(); // Act BomEntry[] entriesForPanasonic = ctrl.GetOrdersForManufacturer(entries, "Panasonic"); // Assert Assert.IsNotNull(entriesForPanasonic); Assert.AreEqual(2, entriesForPanasonic.Length); }
private void LoadData() { txtBomCode.Enabled = false; if (bomCode != null) { Bom bom = BomController.GetBomByCode(this.bomCode); txtBomCode.Text = bom.BomCode.ToString(); txtProductName.Text = bom.Product.ProductName; productCode = bom.Product.ProductCode; BtnSaveAndNew.Visible = false; txtProductName.Enabled = false; btnLovProduct.Enabled = false; } else { } LoadDetail(); }
private void SaveOrder() { try { CheckBeforeSave(); var orderItems = new List <OrderItem>(); int seq = 0; foreach (DataRow row in dtOrderItem.Rows) { DataTable dtBom = BomController.GetBom(row[ConstColumns.PRODUCT_CODE].ToString()); if (dtBom.Rows.Count > 0) { foreach (DataRow dtBomRow in dtBom.Rows) { seq++; //Product productBom = ProductController.GetProduct(dtBomRow[ConstColumns.PRODUCT_CODE].ToString()); orderItems.Add(new OrderItem { OrderNo = txtOrderNo.Text, Seq = seq, Product = new Product { ProductCode = dtBomRow[ConstColumns.PRODUCT_CODE].ToString(), ProductName = "", }, BomCode = (int)dtBomRow["bom_code"], OrderSetQty = Convert.ToInt16(row[ConstColumns.QTY]), OrderSetWgh = Convert.ToInt16(row[ConstColumns.WGH]), OrderQty = Convert.ToInt16(row[ConstColumns.QTY]) * Convert.ToInt16(dtBomRow[ConstColumns.MUTIPLY_QTY]), OrderWgh = Convert.ToInt16(row[ConstColumns.QTY]) * Convert.ToInt16(dtBomRow[ConstColumns.MUTIPLY_QTY]) * Convert.ToDecimal(dtBomRow[ConstColumns.PACKING_SIZE]), }); } } else { seq++; orderItems.Add(new OrderItem { OrderNo = txtOrderNo.Text, Seq = seq, Product = new Product { ProductCode = row[ConstColumns.PRODUCT_CODE].ToString(), ProductName = row[ConstColumns.PRODUCT_NAME].ToString(), }, BomCode = 0, OrderSetQty = 0, OrderSetWgh = 0, OrderQty = Convert.ToInt16(row[ConstColumns.QTY]), OrderWgh = Convert.ToDecimal(row[ConstColumns.WGH]), }); } } var order = new Order { OrderNo = txtOrderNo.Text, RequestDate = dtpRequestDate.Value, Customer = new Customer { CustomerCode = cboCustomer.SelectedValue.ToString() }, Comments = txtComment.Text, OrderFlag = 0, Active = chkActive.Checked, CreateBy = "system", ModifiedBy = "system", OrderItems = orderItems }; if (string.IsNullOrEmpty(txtOrderNo.Text)) { OrderController.Insert(order); } else { OrderController.Update(order); } } catch (Exception) { throw; } }