/// <summary>Harvest the crop.</summary> public void RemoveBiomass(string biomassRemoveType, RemovalFractions removalData = null) { summary.WriteMessage(this, string.Format("Biomass removed from crop " + Name + " by " + biomassRemoveType.TrimEnd('e') + "ing")); // Invoke specific defoliation events. if (biomassRemoveType == "Harvest" && Harvesting != null) { Harvesting.Invoke(this, new EventArgs()); } if (biomassRemoveType == "Prune" && Pruning != null) { Pruning.Invoke(this, new EventArgs()); } if (biomassRemoveType == "LeafPluck" && LeafPlucking != null) { LeafPlucking.Invoke(this, new EventArgs()); } if (biomassRemoveType == "Cut" && Cutting != null) { Cutting.Invoke(this, new EventArgs()); } if (biomassRemoveType == "Graze" && Grazing != null) { Grazing.Invoke(this, new EventArgs()); } // Set up the default BiomassRemovalData values foreach (IOrgan organ in Organs) { // Get the default removal fractions OrganBiomassRemovalType biomassRemoval = null; if (removalData != null) { biomassRemoval = removalData.GetFractionsForOrgan(organ.Name); } organ.RemoveBiomass(biomassRemoveType, biomassRemoval); } // Reset the phenology if SetPhenologyStage specified. if (removalData != null && removalData.SetPhenologyStage != 0 && Phenology is Phenology phenology) { phenology.SetToStage(removalData.SetPhenologyStage); } // Reduce plant and stem population if thinning proportion specified if (removalData != null && removalData.SetThinningProportion != 0 && structure != null) { structure.DoThin(removalData.SetThinningProportion); } // Remove nodes from the main-stem if (removalData != null && removalData.NodesToRemove > 0) { structure.DoNodeRemoval(removalData.NodesToRemove); } }
protected void Assemble(Spectrograms s, Cutting cutting, ref double[][] rmat, int x, int y, int w, int h) { switch (cutting.cut) { case Cutting.Cut.Finished: for (int i = 0; i < w; ++i) { for (int j = 0; j < h; ++j) { rmat[x + i][y + j] = cutting.value; } } return; case Cutting.Cut.Horizontal: Assemble(s, cutting.first, ref rmat, x, y, w / 2, h); Assemble(s, cutting.second, ref rmat, x + w / 2, y, w / 2, h); break; case Cutting.Cut.Vertical: Assemble(s, cutting.first, ref rmat, x, y + h / 2, w, h / 2); Assemble(s, cutting.second, ref rmat, x, y, w, h / 2); break; } }
/// <summary>Cut the crop.</summary> public void Cut() { // Invoke a cutting event. if (Cutting != null) { Cutting.Invoke(this, new EventArgs()); } }
protected static void PrintCutting(Cutting c, string pfx) { if (c.first != null) { if (c.cut == Cutting.Cut.Horizontal) { Console.WriteLine("{0}H", pfx); } else if (c.cut == Cutting.Cut.Vertical) { Console.WriteLine("{0}V", pfx); } PrintCutting(c.first, pfx + " "); PrintCutting(c.second, pfx + " "); } else { Console.WriteLine("{0}* {1}", pfx, c.value); } }
public double[][] Process(float[] inputBuffers) { int minwid = (2 << m_w); // m_w: 8 => 512, 9 => 1024 int maxwid = ((2 << m_w) << m_n); // m_w: 8, m_n: 2 => 2048 // m_w: 9, m_n: 3 => 8192 #if DEBUGVERBOSE Console.WriteLine("Widths from {0} to {1} ({2} to {3} in real parts)", minwid, maxwid, minwid / 2, maxwid / 2); #endif var s = new Spectrograms(minwid / 2, maxwid / 2, 1); int w = minwid; int index = 0; while (w <= maxwid) { if (!IsResolutionWanted(s, w / 2)) { w *= 2; ++index; continue; } if (!m_fftThreads.ContainsKey(w)) { m_fftThreads.Add(w, new FFTThread(w)); } if (m_threaded) { m_fftThreads[w].StartCalculation(inputBuffers, ref s, index, maxwid); } else { m_fftThreads[w].SetParameters(inputBuffers, ref s, index, maxwid); m_fftThreads[w].PerformTask(); } w *= 2; ++index; } if (m_threaded) { w = minwid; index = 0; while (w <= maxwid) { if (!IsResolutionWanted(s, w / 2)) { w *= 2; ++index; continue; } m_fftThreads[w].Await(); w *= 2; ++index; } } m_threadsInUse = false; #if DEBUGVERBOSE Console.WriteLine("maxwid/2 = {0}, minwid/2 = {1}, n+1 = {2}, 2^(n+1) = {3}", maxwid / 2, minwid / 2, m_n + 1, (2 << m_n)); #endif int cutwid = maxwid / 2; Cutting cutting = Cut(s, cutwid, 0, 0, cutwid); #if DEBUGVERBOSE PrintCutting(cutting, " "); #endif var rmat = new double[maxwid / minwid][]; for (int i = 0; i < maxwid / minwid; ++i) { rmat[i] = new double[maxwid / 2]; } Assemble(s, cutting, ref rmat, 0, 0, maxwid / minwid, cutwid); cutting.Erase(); return(rmat); }
private string validating_Pcs_Sqft_For_Cutter(ref Cutting _Cutting, string Lot1, string Pcs, string Sqft, string Lot2, string Pcs2, string Sqft2) { string msg = " "; DataTable dt1 = Cutting_DA.Get_Lot_Pcs_Sqft(_Cutting.Lot_1.ToString()); if (dt1.Rows.Count > 0) { if (_Cutting.Lot_1.ToString() == Lot1.ToString()) { if (_Cutting.Pcs > int.Parse(dt1.Rows[0][0].ToString()) + int.Parse(Pcs)) { msg += "Using More Pcs then Then you have in Lot1 </br>"; } if (_Cutting.Sqft > float.Parse(dt1.Rows[0][1].ToString()) + float.Parse(Sqft)) { msg += "Using More Sqft then Then you have in Lot1 </br>"; } } else { if (_Cutting.Pcs > int.Parse(dt1.Rows[0][0].ToString())) { msg += "Using More Pcs then Then you have in Lot1 </br>"; } if (_Cutting.Sqft > float.Parse(dt1.Rows[0][1].ToString())) { msg += "Using More Sqft then Then you have in Lot1 </br>"; } } } if (_Cutting.Lot_2 != null) { DataTable dt2 = Cutting_DA.Get_Lot_Pcs_Sqft(_Cutting.Lot_2.ToString()); if (dt2.Rows.Count > 0) { if (_Cutting.Lot_2.ToString() == Lot2.ToString()) { if (_Cutting.Pcs2 > int.Parse(dt2.Rows[0][0].ToString()) + int.Parse(Pcs2)) { msg += "Using More Pcs then you have in Lot2 </br>"; } if (_Cutting.Sqft2 > float.Parse(dt2.Rows[0][1].ToString()) + float.Parse(Sqft2)) { msg += "Using More Sqft then you have in Lot2 </br>"; } } else { if (_Cutting.Pcs2 > int.Parse(dt2.Rows[0][0].ToString())) { msg += "Using More Pcs then you have in Lot2 </br>"; } if (_Cutting.Sqft2 > float.Parse(dt2.Rows[0][1].ToString())) { msg += "Using More Sqft then you have in Lot2 </br>"; } } } } return msg; }
private void validating_Pcs_Sqft_For_Cutter(ref Cutting _Cutting) { DataTable dt1 = Cutting_DA.Get_Lot_Pcs_Sqft(_Cutting.Lot_1.ToString()); if (dt1.Rows.Count > 0) { if (_Cutting.Pcs > int.Parse(dt1.Rows[0][0].ToString())) { lblMessage.Text += "Using More Pcs then Then you have in Lot1 </br>"; } if (_Cutting.Sqft > float.Parse(dt1.Rows[0][1].ToString())) { lblMessage.Text += "Using More Sqft then Then you have in Lot1 </br>"; } } if (_Cutting.Lot_2 != null) { DataTable dt2 = Cutting_DA.Get_Lot_Pcs_Sqft(_Cutting.Lot_2.ToString()); if (_Cutting.Pcs2 > int.Parse(dt2.Rows[0][0].ToString())) { lblMessage.Text += "Using More Pcs then you have in Lot2 </br>"; } if (_Cutting.Sqft2 > float.Parse(dt2.Rows[0][1].ToString())) { lblMessage.Text += "Using More Sqft then you have in Lot2 </br>"; } } }
private bool Validate_Lot_Order() { lblMessage.Text = ""; lblMessage.ForeColor = System.Drawing.Color.Red; bool flag = false; #region Cutting Cutting _Cutting = new Cutting(); if (ddlCutter.SelectedValue != "") { _Cutting.Employee = int.Parse(ddlCutter.SelectedValue); } if (ddlCompany.SelectedValue != "") { _Cutting.Company = int.Parse(ddlCompany.SelectedValue); } if (ddlMarket.SelectedValue != "") { _Cutting.Market = int.Parse(ddlMarket.SelectedValue); } _Cutting.Order = int.Parse(ddlOrderNo.SelectedValue); _Cutting.Style = int.Parse(ddlStyle.SelectedValue); _Cutting.Size = int.Parse(ddlSize.SelectedValue); _Cutting.Pairs = int.Parse(txtPairs.Text); if (divPcsSqft.Visible == true) { _Cutting.Lot_1 = int.Parse(ddlLot1.SelectedValue); _Cutting.Pcs = int.Parse(txtPcs.Text); _Cutting.Sqft = float.Parse(txtSqFt.Text); } if (divLot2.Visible == true) { _Cutting.Lot_2 = int.Parse(ddlLot2.SelectedValue); _Cutting.Pcs2 = int.Parse(txtPcs2.Text); _Cutting.Sqft2 = float.Parse(txtSqFt2.Text); } _Cutting.Date = Convert.ToDateTime(txtDate.Text); #endregion if (_Cutting.Employee!=null) { bool Order = Cutting_DA.IsOrderBeforeCutting(_Cutting), Lot = Cutting_DA.IsLotBeforeCutting(_Cutting); // for Cutter flag = Order && Lot ? true : false; if (!flag) { if (!Order) { lblMessage.Text = "Your Cutting Date is earlier than Order <br>"; } if (!Lot) { lblMessage.Text += "Your Cutting Date is earlier than lot"; } } } else { // for Compnay and market flag = Cutting_DA.IsOrderBeforeCutting(_Cutting); if (!flag) { lblMessage.Text = "Your Cutting Date is earlier than Order"; } } return flag; }
protected bool ValidatePage() { bool flag = true; #region Cutting Cutting _Cutting = new Cutting(); if (ddlCutter.SelectedValue != "") _Cutting.Employee = int.Parse(ddlCutter.SelectedValue); else _Cutting.Company = int.Parse(ddlCompany.SelectedValue); if (ddlOrderNo.SelectedValue != "") _Cutting.Order = int.Parse(ddlOrderNo.SelectedValue); if (ddlStyle.SelectedValue != "") _Cutting.Style = int.Parse(ddlStyle.SelectedValue); if (ddlSize.SelectedValue != "") _Cutting.Size = int.Parse(ddlSize.SelectedValue); if (divPcsSqft.Visible == true) { _Cutting.Lot_1 = int.Parse(ddlLot1.SelectedValue); _Cutting.Pcs = int.Parse(txtPcs.Text); _Cutting.Sqft = float.Parse(txtSqFt.Text); if (divLot2.Visible == true) { _Cutting.Lot_2 = int.Parse(ddlLot2.SelectedValue); _Cutting.Pcs2 = int.Parse(txtPcs2.Text); _Cutting.Sqft2 = float.Parse(txtSqFt2.Text); } } _Cutting.Pairs = int.Parse(txtPairs.Text); #endregion validatingPairs(ref _Cutting); if (ddlCutter.SelectedValue != "") validating_Pcs_Sqft_For_Cutter(ref _Cutting); //else //validating_Pcs_Sqft_For_Company(ref flag, ref _Cutting); if (flag == false) lblMessage.ForeColor = System.Drawing.Color.Red; else lblMessage.ForeColor = System.Drawing.Color.Green; return flag; }
protected void Fill_Style() { Cutting _Cutting = new Cutting(); if (ddlOrderNo.SelectedValue != "") { _Cutting.Order = int.Parse(ddlOrderNo.SelectedValue); } if (ddlStyle.SelectedValue != "") { _Cutting.Style = int.Parse(ddlStyle.SelectedValue); } if (ddlSize.SelectedValue != "") { _Cutting.Size = int.Parse(ddlSize.SelectedValue); } DataTable dt = Cutting_DA.Get_Style(_Cutting); if (ddlStyle.SelectedValue == "") { if (dt.Rows.Count == 0) ddlStyle.Items.Clear(); else { ddlStyle.DataSource = dt; ddlStyle.DataTextField = "Name"; ddlStyle.DataValueField = "Id"; ddlStyle.DataBind(); } ddlStyle.Items.Insert(0, new ListItem(Constants.SELECT_HERE, "")); ddlStyle.SelectedIndex = 0; } }
// Validation public static bool IsOrderBeforeCutting(Cutting _Cutting) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_IsOrderBeforeCutting"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@OrderId"; param.Value = _Cutting.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@StyleId"; param.Value = _Cutting.Style; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@SizeId"; param.Value = _Cutting.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Date"; param.Value = _Cutting.Date; param.DbType = DbType.Date; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); if (command.Parameters["@Return"].Value.ToString() == "1") { return true; } else { return false; } }
protected void PerformTask() { m_result = m_as.Cut(m_s, m_res, m_x, m_y, m_h); }
protected void GetSubCuts(Spectrograms s, int res, int x, int y, int h, ref Cutting top, ref Cutting bottom, ref Cutting left, ref Cutting right) { if (m_threaded && !m_threadsInUse) { m_threadsInUse = true; if (m_cutThreads.Count == 0) { for (int i = 0; i < 4; ++i) { var t = new CutThread(this); m_cutThreads.Add(t); } } // Cut threads 0 and 1 calculate the top and bottom halves; // threads 2 and 3 calculate left and right. See notes in // unthreaded code below for more information. if (top != null) { m_cutThreads[0].Cut(s, res, x, y + h / 2, h / 2); } if (bottom != null) { m_cutThreads[1].Cut(s, res, x, y, h / 2); } if (left != null) { m_cutThreads[2].Cut(s, res / 2, 2 * x, y / 2, h / 2); } if (right != null) { m_cutThreads[3].Cut(s, res / 2, 2 * x + 1, y / 2, h / 2); } // you shouldn't get here before all the cut threads have finished if (top != null) { top = m_cutThreads[0].Get(); } if (bottom != null) { bottom = m_cutThreads[1].Get(); } if (left != null) { left = m_cutThreads[2].Get(); } if (right != null) { right = m_cutThreads[3].Get(); } } else { // Unthreaded version // The "vertical" division is a top/bottom split. // Splitting this way keeps us in the same resolution, // but with two vertical subregions of height h/2. if (top != null) { top = Cut(s, res, x, y + h / 2, h / 2); } if (bottom != null) { bottom = Cut(s, res, x, y, h / 2); } // The "horizontal" division is a left/right split. // Splitting this way places us in resolution res/2, which has lower // vertical resolution but higher horizontal resolution. // We need to double x accordingly. if (left != null) { left = Cut(s, res / 2, 2 * x, y / 2, h / 2); } if (right != null) { right = Cut(s, res / 2, 2 * x + 1, y / 2, h / 2); } } }
// recursively cut the spectrogram into small pieces protected Cutting Cut(Spectrograms s, int res, int x, int y, int h) { #if DEBUGVERBOSE Console.WriteLine("res = {0}, x = {1}, y = {2}, h = {3}", res, x, y, h); #endif var cutting = new Cutting(); if (h > 1 && res > s.minres) { if (!IsResolutionWanted(s, res)) { var left = new Cutting(); var right = new Cutting(); //GetSubCuts(s, res, x, y, h, null, null, ref left, ref right); double hcost = left.cost + right.cost; double henergy = left.value + right.value; hcost = Normalize(hcost, henergy); cutting.cut = Cutting.Cut.Horizontal; cutting.first = left; cutting.second = right; cutting.cost = hcost; cutting.value = left.value + right.value; } else if (h == 2 && !IsResolutionWanted(s, res / 2)) { var top = new Cutting(); var bottom = new Cutting(); //GetSubCuts(s, res, x, y, h, ref top, ref bottom, null, null); double vcost = top.cost + bottom.cost; double venergy = top.value + bottom.value; vcost = Normalize(vcost, venergy); cutting.cut = Cutting.Cut.Vertical; cutting.first = top; cutting.second = bottom; cutting.cost = vcost; cutting.value = top.value + bottom.value; } else { var top = new Cutting(); var bottom = new Cutting(); var left = new Cutting(); var right = new Cutting(); GetSubCuts(s, res, x, y, h, ref top, ref bottom, ref left, ref right); double vcost = top.cost + bottom.cost; double venergy = top.value + bottom.value; vcost = Normalize(vcost, venergy); double hcost = left.cost + right.cost; double henergy = left.value + right.value; hcost = Normalize(hcost, henergy); if (vcost > hcost) { cutting.cut = Cutting.Cut.Horizontal; cutting.first = left; cutting.second = right; cutting.cost = hcost; cutting.value = left.value + right.value; top.Erase(); bottom.Erase(); return(cutting); } else { cutting.cut = Cutting.Cut.Vertical; cutting.first = top; cutting.second = bottom; cutting.cost = vcost; cutting.value = top.value + bottom.value; left.Erase(); right.Erase(); return(cutting); } } } else { // no cuts possible from this level cutting.cut = Cutting.Cut.Finished; cutting.first = null; cutting.second = null; int n = 0; for (int r = res; r > s.minres; r >>= 1) { ++n; } Spectrogram spectrogram = s.spectrograms[n]; cutting.cost = Cost(spectrogram, x, y); cutting.value = Value(spectrogram, x, y); } return(cutting); }
private static void ComputeVertexCuttingTop(Cutting cutting, ref List<Vertex> listVertex, ref List<int> listVertexIndex) { if (cutting.Cuttings.Count == 0 && !cutting.IsEmpty) { float d = 40f; float height = 0f; if (cutting.ParentFolding != null) height = cutting.ParentFolding.Height / d; float deep = 0f; if (cutting.ParentFolding != null) deep = -cutting.ParentFolding.RecFaceWithoutDelta.Top / d + height; //--- 1 Vertex vertex = new Vertex(); vertex.X = cutting.Rectangle.Right / d; vertex.Z = deep; vertex.Y = -cutting.Rectangle.Top / d - deep; int index = AddVertexToList(ref listVertex, vertex); listVertexIndex.Add(index); //--- //--- 2 vertex = new Vertex(); vertex.X = cutting.Rectangle.Left / d; vertex.Z = deep; vertex.Y = -cutting.Rectangle.Top / d - deep; index = AddVertexToList(ref listVertex, vertex); listVertexIndex.Add(index); //--- //--- 3 vertex = new Vertex(); vertex.X = cutting.Rectangle.Left / d; vertex.Z = deep; vertex.Y = -cutting.Rectangle.Bottom / d - deep; index = AddVertexToList(ref listVertex, vertex); listVertexIndex.Add(index); //--- //--- 4 vertex = new Vertex(); vertex.X = cutting.Rectangle.Right / d; vertex.Z = deep; vertex.Y = -cutting.Rectangle.Bottom / d - deep; index = AddVertexToList(ref listVertex, vertex); listVertexIndex.Add(index); //--- } else { foreach (Cutting cuttingChild in cutting.Cuttings) { ComputeVertexCuttingTop(cuttingChild, ref listVertex, ref listVertexIndex); } } }
protected void Fill_PairsBox() { if (ddlOrderNo.SelectedValue != "" && ddlSize.SelectedValue != "" && ddlStyle.SelectedValue != "") { Cutting _Cutting = new Cutting(); _Cutting.Order = int.Parse(ddlOrderNo.SelectedValue); _Cutting.Style = int.Parse(ddlStyle.SelectedValue); _Cutting.Size = int.Parse(ddlSize.SelectedValue); DataTable dt = Cutting_DA.Get_Pairs(_Cutting); if (dt.Rows.Count > 0) { txtPairs.Text = dt.Rows[0][0].ToString(); lblPairsRemaining.Text = dt.Rows[0][0].ToString(); lblPairsCutted.Text = dt.Rows[0][2].ToString(); lblShippingDate.Text = Convert.ToDateTime(dt.Rows[0][1].ToString()).ToString("MM/dd/yyyy"); //txtDate.Text = Convert.ToDateTime(dt.Rows[0][1].ToString()).ToString("yyyy-MM-dd"); } else { txtPairs.Text = ""; lblShippingDate.Text = ""; } } }
public static string UpdateCutting(Cutting _Cutting) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_UpdateCutting"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Id"; param.Value = _Cutting.Id; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Lot_1"; param.Value = _Cutting.Lot_1; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Lot_2"; param.Value = _Cutting.Lot_2; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pcs"; param.Value = _Cutting.Pcs; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Sqft"; param.Value = _Cutting.Sqft; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pcs2"; param.Value = _Cutting.Pcs2; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Sqft2"; param.Value = _Cutting.Sqft2; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Date"; param.Value = _Cutting.Date; param.DbType = DbType.Date; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Description"; param.Value = _Cutting.Description; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Gp_No"; param.Value = _Cutting.Gp_No; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Order"; param.Value = _Cutting.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Style"; param.Value = _Cutting.Style; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Size"; param.Value = _Cutting.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pairs"; param.Value = _Cutting.Pairs; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Cutter"; param.Value = _Cutting.Employee; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Company"; param.Value = _Cutting.Company; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Market"; param.Value = _Cutting.Market; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Remarks"; param.Value = _Cutting.Remarks; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); return command.Parameters["@Return"].Value.ToString(); }
protected void InsertCutting() { #region Cutting Cutting _Cutting = new Cutting(); if (ddlCutter.SelectedValue != "") { _Cutting.Employee = int.Parse(ddlCutter.SelectedValue); } if (ddlCompany.SelectedValue != "") { _Cutting.Company = int.Parse(ddlCompany.SelectedValue); } if (ddlMarket.SelectedValue != "") { _Cutting.Market = int.Parse(ddlMarket.SelectedValue); } _Cutting.Order = int.Parse(ddlOrderNo.SelectedValue); _Cutting.Style = int.Parse(ddlStyle.SelectedValue); _Cutting.Size = int.Parse(ddlSize.SelectedValue); _Cutting.Pairs = int.Parse(txtPairs.Text); if (divPcsSqft.Visible == true) { _Cutting.Lot_1 = int.Parse(ddlLot1.SelectedValue); _Cutting.Pcs = int.Parse(txtPcs.Text); _Cutting.Sqft = float.Parse(txtSqFt.Text); } if (divLot2.Visible == true) { _Cutting.Lot_2 = int.Parse(ddlLot2.SelectedValue); _Cutting.Pcs2 = int.Parse(txtPcs2.Text); _Cutting.Sqft2 = float.Parse(txtSqFt2.Text); } _Cutting.Date = Convert.ToDateTime(txtDate.Text); _Cutting.Description = txtDescription.Text; _Cutting.Gp_No = txtGp_No.Text; _Cutting.Remarks = txtRemarks.Text; _Cutting.Is_Paid = false; _Cutting.IsDeleted = false; #endregion lblMessage.Text += Cutting_DA.InsertCutting(_Cutting); if (!lblMessage.Text.Contains(Constants.ALREADY_EXIST)) { if (ddlCutter.SelectedValue != "") { UpdateDeliveryForInstockCutting(); } else if (ddlCompany.SelectedValue != "") { Cutting_DA.Update_Outstock_For_Cutting(ddlCompany.SelectedValue); } lblMessage.ForeColor = System.Drawing.Color.Green; Response.Write("<script>alert('Inserted Successfully'); document.location='/forms/formCutting';</script>"); } else { lblMessage.ForeColor = System.Drawing.Color.Red; } }
public static DataTable Get_Style(Cutting _Cutting) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_Get_Style"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@OrderId"; param.Value = _Cutting.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@SizeId"; param.Value = _Cutting.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); return Catalog_Access.ExecuteSelectCommand(command); }
protected void validatingPairs(ref Cutting _Cutting) { DataTable dt = Cutting_DA.Get_Pairs(_Cutting); if (dt.Rows.Count > 0) { if (_Cutting.Pairs > int.Parse(dt.Rows[0][0].ToString())) { lblMessage.Text += "Making More Pairs then required </br>"; } } }
public static string InsertCutting(Cutting _Cutting) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_insertCutting"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Lot_1"; param.Value = _Cutting.Lot_1; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Lot_2"; param.Value = _Cutting.Lot_2; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pcs"; param.Value = _Cutting.Pcs; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Sqft"; param.Value = _Cutting.Sqft; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pcs2"; param.Value = _Cutting.Pcs2; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Sqft2"; param.Value = _Cutting.Sqft2; param.DbType = DbType.Decimal; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Date"; param.Value = _Cutting.Date; param.DbType = DbType.Date; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Description"; param.Value = _Cutting.Description; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Gp_No"; param.Value = _Cutting.Gp_No; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Order"; param.Value = _Cutting.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Style"; param.Value = _Cutting.Style; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Size"; param.Value = _Cutting.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Pairs"; param.Value = _Cutting.Pairs; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Employee"; param.Value = _Cutting.Employee; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Company"; param.Value = _Cutting.Company; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Market"; param.Value = _Cutting.Market; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Is_Paid"; param.Value = _Cutting.Is_Paid; param.DbType = DbType.Boolean; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Remarks"; param.Value = _Cutting.Remarks; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@IsDeleted"; param.Value = _Cutting.IsDeleted; param.DbType = DbType.Boolean; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); string Return = command.Parameters["@Return"].Value.ToString(); if (Return == Constants.SP_ALREADY_EXIST) { return Constants.ALREADY_EXIST; } else { return Constants.SUCESS_INSERT; } }
private void validating_Pcs_Sqft_For_Company(ref bool flag, ref Cutting _Cutting) { }
protected bool ValidatePage() { bool flag = true; #region Cutting Cutting _Cutting = new Cutting(); _Cutting.Lot_1 = int.Parse(ddlLot1.SelectedValue); _Cutting.Pcs = int.Parse(txtPcs.Text); _Cutting.Sqft = float.Parse(txtSqFt.Text); if (divLot2.Visible == true) { _Cutting.Lot_2 = int.Parse(ddlLot2.SelectedValue); _Cutting.Pcs2 = int.Parse(txtPcs2.Text); _Cutting.Sqft2 = float.Parse(txtSqFt2.Text); } #endregion validating_Pcs_Sqft_For_Cutter(ref _Cutting); //else //validating_Pcs_Sqft_For_Company(ref flag, ref _Cutting); if (flag == false) lblMessage.ForeColor = System.Drawing.Color.Red; else lblMessage.ForeColor = System.Drawing.Color.Green; return flag; }
public string Update(int Id, int Lot1, int Pcs, float Sqft, int Lot2, int Pcs2, float Sqft2, string Description, string Date) { WadaGhata _WadaGhata = new WadaGhata(); _WadaGhata.Id = Id; _WadaGhata.Lot_1 = Lot1; if (Lot2 != -1) { _WadaGhata.Lot_2 = Lot2; _WadaGhata.Pcs2 = Pcs2; _WadaGhata.Sqft2 = Sqft2; } _WadaGhata.Pcs = Pcs; _WadaGhata.Sqft = Sqft; _WadaGhata.Date = Convert.ToDateTime(Date); _WadaGhata.Description = Description; #region Cutting Cutting _Cutting = new Cutting(); _Cutting.Lot_1 = Lot1; if (Lot2 != -1) { _Cutting.Lot_2 = Lot2; _Cutting.Pcs2 = Pcs2; _Cutting.Sqft2 = Sqft2; } _Cutting.Pcs = Pcs; _Cutting.Sqft = Sqft; #endregion string msg = Validate_Lot(_WadaGhata); if (msg == "") { DataTable dt = WadaGhata_DA.Get_WadaGhata_By_ID(Id); msg = validating_Pcs_Sqft_For_Cutter(ref _Cutting, dt.Rows[0]["Lot_1"].ToString(), dt.Rows[0]["Pcs"].ToString(), dt.Rows[0]["Sqft"].ToString(), dt.Rows[0]["Lot_2"].ToString(), dt.Rows[0]["Pcs2"].ToString(), dt.Rows[0]["Sqft2"].ToString()); msg += WadaGhata_DA.UpdateWadaGhata(_WadaGhata); OldPcsSqftEntry(dt.Rows[0]["Lot_1"].ToString(), dt.Rows[0]["Pcs"].ToString(), dt.Rows[0]["Sqft"].ToString()); if (dt.Rows[0]["Lot_2"].ToString() != "") OldPcsSqftEntry(dt.Rows[0]["Lot_2"].ToString(), dt.Rows[0]["Pcs2"].ToString(), dt.Rows[0]["Sqft2"].ToString()); UpdateDeliveryForWadaGhata(Lot1, Pcs, Sqft, Lot2, Pcs2, Sqft2); if (Session["User"].ToString().ToUpper() != ("Mustafa Piracha").ToUpper()) { SendNotification(_WadaGhata, dt); } } return msg; }
private void DrawCutting(Cutting cutting, Brush brush) { if (cutting.Cuttings.Count == 0) { /* Rectangle rec2 = cutting.Rectangle; rec2.X += 1; rec2.Y += 1+Common.lineMidScreen.P1.Y; rec2.Width -= 2; rec2.Height -= 2; */ if (!cutting.IsEmpty) { gBmp.FillRectangle(brush, cutting.Rectangle.Left + Common.Delta.X, cutting.Rectangle.Top + Common.Delta.Y, cutting.Rectangle.Width, cutting.Rectangle.Height); //gBmp.DrawRectangle(Pens.Red, rec2); } else { //gBmp.DrawRectangle(Pens.Yellow, rec2); } } else { foreach (Cutting cuttingChild in cutting.Cuttings) { DrawCutting(cuttingChild, brush); } } }
private void DrawCuttingTop(Cutting cutting, Rectangle rec, Brush brush) { if (cutting.Cuttings.Count == 0) { Rectangle rec2 = cutting.Rectangle; if (!cutting.IsEmpty) { rec2.Intersect(rec); if (!rec2.IsEmpty) gBmp.FillRectangle(brush, rec2.Left + Common.Delta.X, rec2.Top + Common.Delta.Y, rec2.Width, rec2.Height); //gBmp.DrawRectangle(Pens.Red, rec2); } else { //gBmp.DrawRectangle(Pens.Yellow, rec2); } } else { foreach (Cutting cuttingChild in cutting.Cuttings) { DrawCuttingTop(cuttingChild, rec, brush); } } }
private void IntersectCutting(Cutting parent, Rectangle rec2) { if (!parent.IsEmpty) { Rectangle rec = parent.Rectangle; if (rec.IntersectsWith(rec2)) { if (parent.Cuttings.Count > 0) { foreach (Cutting cutting in parent.Cuttings) { IntersectCutting(cutting, rec2); } } else { // Découpage du cutting int[] locW = new int[2] { rec.Left, rec.Right }; int[] locH = new int[2] { rec.Top, rec.Bottom }; bool[] visibleW = new bool[1] { false }; bool[] visibleH = new bool[1] { false }; // _____ //|.....| //|.....| //|_____| //| | //| | //|_____| if (rec2.Top <= rec.Top && rec2.Bottom < rec.Bottom && rec2.Bottom > rec.Top) { locH = new int[3] { rec.Top, rec2.Bottom, rec.Bottom }; visibleH = new bool[2] { false, true }; } // _____ //| | //| | //|_____| //|.....| //|.....| //|_____| //| | //| | //|_____| else if(rec2.Top > rec.Top && rec2.Bottom < rec.Bottom) { locH = new int[4] { rec.Top, rec2.Top, rec2.Bottom, rec.Bottom }; visibleH = new bool[3] { true, false, true }; } // _____ //| | //| | //|_____| //|.....| //|.....| //|_____| else if (rec2.Top > rec.Top && rec2.Top < rec.Bottom && rec2.Bottom >= rec.Bottom) { locH = new int[3] { rec.Top, rec2.Top, rec.Bottom }; visibleH = new bool[2] { true, false }; } // _____ ____ //|.....| | //|.....| | //|_____|_____| if (rec2.Left <= rec.Left && rec2.Right < rec.Right && rec2.Right > rec.Left) { locW = new int[3] { rec.Left, rec2.Right, rec.Right }; visibleW = new bool[2] { false, true }; } // _____ _____ _____ //| |.....| | //| |.....| | //|_____|_____|_____| else if (rec2.Left > rec.Left && rec2.Right < rec.Right) { locW = new int[4] { rec.Left, rec2.Left, rec2.Right, rec.Right }; visibleW = new bool[3] { true, false, true }; } // _____ ____ //| |.....| //| |.....| //|_____|_____| else if (rec2.Left > rec.Left && rec2.Left < rec.Right && rec2.Right >= rec.Right) { locW = new int[3] { rec.Left, rec2.Left, rec.Right }; visibleW = new bool[2] { true, false }; } for (int x = 0; x < locW.Length - 1; x++) { for (int y = 0; y < locH.Length - 1; y++) { Cutting cutting = new Cutting(parent.ParentFolding); cutting.Rectangle = new Rectangle(locW[x], locH[y], locW[x + 1] - locW[x], locH[y + 1] - locH[y]); cutting.IsEmpty = (!visibleW[x] && !visibleH[y]); parent.Cuttings.Add(cutting); } } } } } }
void Start() { cutting = this.GetComponent <Cutting>(); }
private void OnCut() { Cutting.Invoke(); }