public OrderHeadDialog(SessionInfo _session, IEnumerable<OrderHeadModel> model) { InitializeComponent(); _repo = new SaleOrderRepo(); _selected = new OrderHeadModel(); list = model; epiSession = _session; }
private void butSelect_Click(object sender, EventArgs e) { if (dgvList.Rows.Count >= 1) { int iRow = dgvList.CurrentRow.Index; string orderID = dgvList.Rows[iRow].Cells["orderid"].Value.ToString(); if (!string.IsNullOrEmpty(orderID)) { _selected = _repo.GetOrderByID(orderID); this.Close(); } } }
private void dgvCutting_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (OrderCompleted()) return; OrderHeadModel result = new OrderHeadModel(); int i; decimal d; string riskFlag = string.Empty; string msg = string.Empty; string colName = dgvCutting.Columns[e.ColumnIndex].Name; string lineId = dgvCutting.Rows[e.RowIndex].Cells["lineid"].Value.GetString(); string resultValue = dgvCutting.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetString(); bool changeState = false; CutDesignModel rowData = new CutDesignModel(); rowData = (from item in HeaderContent.CuttingDesign where item.LineID == Convert.ToInt32(lineId) select item).FirstOrDefault(); rowData.CompleteRow = false; switch (colName) { case "sono": #region Verify S/O No. if (HeaderContent.Materials.ToList().Count == 0) HeaderContent.BussinessType = ""; if (HeaderContent.CuttingDesign.ToList().Count == 1) HeaderContent.BussinessType = ""; if (!string.IsNullOrEmpty(resultValue) && rowData.SONo != resultValue) { var resultTmp = _repoSale.GetOrderHeader(HeaderContent, resultValue).ToList(); dgvCutting.Rows[e.RowIndex].Cells["soline"].Value = string.Empty; if (resultTmp.ToList().Count == 0) { var soResult = _repoSale.GetOrderHeader(HeaderContent); using (OrderHeadDialog frm = new OrderHeadDialog(epiSession, soResult)) { frm.ShowDialog(); result = frm._selected; if (result == null) { dgvCutting.Rows[e.RowIndex].Cells["sono"].Value = string.Empty; dgvCutting.Rows[e.RowIndex].Cells["soline"].Value = string.Empty; return; } } } else { result = resultTmp.FirstOrDefault(); } //Set header value. HeaderContent.OrderType = result.OrderType; if (!string.IsNullOrEmpty(result.OrderNumber)) { HeaderContent.CuttingDesign = addSOLine(Convert.ToInt32(lineId), result.OrderNumber); rowData = (from item in HeaderContent.CuttingDesign where item.LineID == Convert.ToInt32(lineId) select item).FirstOrDefault(); dgvCutting.Rows[e.RowIndex].Cells["sono"].Value = rowData.SONo; dgvCutting.Rows[e.RowIndex].Cells["customer"].Value = result.CustID; dgvCutting.Rows[e.RowIndex].Cells["soline"].Value = rowData.SOLine; dgvCutting.Rows[e.RowIndex].Cells["norno"].Value = rowData.NORNum; dgvCutting.Rows[e.RowIndex].Cells["commodity1"].Value = rowData.CommodityCode; dgvCutting.Rows[e.RowIndex].Cells["spec1"].Value = rowData.SpecCode; dgvCutting.Rows[e.RowIndex].Cells["coating1"].Value = rowData.CoatingCode; dgvCutting.Rows[e.RowIndex].Cells["thick1"].Value = rowData.Thick; dgvCutting.Rows[e.RowIndex].Cells["width1"].Value = rowData.Width; dgvCutting.Rows[e.RowIndex].Cells["length1"].Value = rowData.Length; dgvCutting.Rows[e.RowIndex].Cells["status1"].Value = ""; dgvCutting.Rows[e.RowIndex].Cells["soweight"].Value = rowData.SOWeight; dgvCutting.Rows[e.RowIndex].Cells["soqty"].Value = rowData.SOQuantity; dgvCutting.Rows[e.RowIndex].Cells["qtyPack1"].Value = rowData.QtyPack; dgvCutting.Rows[e.RowIndex].Cells["pack"].Value = rowData.Pack; dgvCutting.Rows[e.RowIndex].Cells["bt1"].Value = rowData.BussinessType; } else { dgvCutting.Rows[e.RowIndex].Cells["sono"].Value = rowData.SONo; } } #endregion Verify S/O No. break; case "soline": changeState = (rowData.SOLine != Convert.ToInt32(resultValue)); rowData.SOLine = Convert.ToInt32(string.IsNullOrEmpty(resultValue) ? "0" : resultValue); break; case "width1": if (!decimal.TryParse(resultValue, out d)) { //e.Cancel = true; return; } changeState = (rowData.Width != Convert.ToDecimal(resultValue)); rowData.Width = Convert.ToDecimal(string.IsNullOrEmpty(resultValue) ? "0M" : resultValue); break; case "length1": if (!decimal.TryParse(resultValue, out d)) { return; } changeState = (rowData.Length != Convert.ToDecimal(resultValue)); rowData.Length = Convert.ToDecimal(string.IsNullOrEmpty(resultValue) ? "0M" : resultValue); break; case "status1": changeState = (rowData.Status != resultValue); if (changeState) { if (HeaderContent.ProcessLine.ResourceGrpID == "L") { if (resultValue == "F" && !string.IsNullOrEmpty(rowData.NORNum)) { dgvCutting.Rows[e.RowIndex].Cells["length1"].ReadOnly = true; } else { dgvCutting.Rows[e.RowIndex].Cells["length1"].ReadOnly = false; } } else if (HeaderContent.ProcessLine.ResourceGrpID == "S") { if (resultValue == "S" && !string.IsNullOrEmpty(rowData.NORNum)) { dgvCutting.Rows[e.RowIndex].Cells["width1"].ReadOnly = true; } else { dgvCutting.Rows[e.RowIndex].Cells["width1"].ReadOnly = false; } } } rowData.Status = resultValue; break; case "stand": if (!int.TryParse(resultValue, out i)) { return; } changeState = (rowData.Stand != Convert.ToInt32(resultValue)); rowData.Stand = Convert.ToInt32(resultValue); break; case "cutdiv": if (!int.TryParse(resultValue, out i)) { return; } changeState = (rowData.CutDivision != Convert.ToInt32(resultValue)); rowData.CutDivision = Convert.ToInt32(resultValue); break; case "note1": changeState = (rowData.Note != resultValue); rowData.Note = resultValue; break; case "soqty": changeState = (rowData.SOQuantity != Convert.ToDecimal(resultValue)); rowData.SOQuantity = Convert.ToDecimal(resultValue); break; case "calqty": changeState = (rowData.CalQuantity != Convert.ToDecimal(resultValue)); rowData.CalQuantity = Convert.ToDecimal(resultValue); break; case "qtyPack1": changeState = (rowData.QtyPack != Convert.ToDecimal(resultValue)); rowData.QtyPack = Convert.ToDecimal(resultValue); break; } if (changeState) { rowData.CalculateRows(HeaderContent); bool validRow = rowData.ValidateByRow(HeaderContent, out riskFlag, out msg); dgvCutting.Rows[e.RowIndex].Cells["rowValidated"].Value = validRow; if (!validRow) { if (riskFlag == "ERROR") { DialogResult diaResult = MessageBox.Show(msg, "Row validate error!.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //Set rial time to change weight by row. dgvCutting.Rows[e.RowIndex].Cells["unitweight1"].Value = rowData.UnitWeight; dgvCutting.Rows[e.RowIndex].Cells["totalweight"].Value = rowData.TotalWeight; dgvCutting.Rows[e.RowIndex].Cells["totallength"].Value = rowData.TotalLength; rowData.CompleteRow = validRow; HeaderContent.CuttingDesign = _repo.SaveLineCutting(epiSession, HeaderContent, rowData).ToList(); SetHeadContent(HeaderContent); ListMaterialGrid(HeaderContent.Materials); } }
public IEnumerable<OrderHeadModel> GetOrderHeadByFilter(OrderHeadModel data, PlanningHeadModel model) { IEnumerable<OrderHeadModel> query = GetOrderHeader(model); return query; }