Exemple #1
0
 public Tire(string name, int profileWidth, int profileHeight, CarcassType type, int diameter)
 {
     Name          = name;
     ProfileWidth  = profileWidth;
     ProfileHeight = profileHeight;
     Type          = type;
     Diameter      = diameter;
 }
Exemple #2
0
        /// <summary>
        /// Создание шины из строкового представления
        /// </summary>
        /// <param name="str">Строковое представление (пример: "Hakkapelita 175/60 R15")</param>
        public static Tire FromString(string str)
        {
            Regex regex = new Regex("^(\\w+) (\\d+)/(\\d+) (D|R|B)(\\d+)$");

            if (!regex.IsMatch(str))
            {
                throw new FileFormatException();
            }
            var         match       = regex.Match(str);
            CarcassType carcassType = match.Groups[4].Value == "D"
                ? CarcassType.Diagonal
                : (match.Groups[4].Value == "R" ? CarcassType.Radial : CarcassType.BiasBelt);

            return(new Tire(match.Groups[1].Value, int.Parse(match.Groups[2].Value),
                            int.Parse(match.Groups[3].Value), carcassType, int.Parse(match.Groups[5].Value)));
        }
Exemple #3
0
 private void CarcassType_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(CarcassType.Text) && CarcassType.Text.Length > 5)
     {
         CType = CarcassType.Text.Substring(0, 5);
     }
     if (CarcassType.Text == "")
     {
         MessageBox.Show("Invalid Carcass Type Please confirm before proceeding");
         if (ReceiptNo.Text != "" && SlapMark.Text != "" && Weight.Text != "")
         {
             CarcassType.Focus();
         }
     }
     else
     {
         MeatPercent.Enabled  = true;
         MeatPercent.ReadOnly = false;
     }
 }
        public static Car CreateCar(string manufacturer, string model, CarcassType carcassType, int horsePowers = 90, float wheelDiameter = 27, float engineVolume = 1.5f, FuelType fuelType = FuelType.Diesel)
        {
            Car car = new Car()
            {
                Model = model, Manufacturer = manufacturer, Engine = new Engine()
            };

            car.Model = model;
            if (string.IsNullOrEmpty(model))
            {
                car.Model = "Unknown model";
            }

            car.Manufacturer = manufacturer;
            if (string.IsNullOrEmpty(manufacturer))
            {
                car.Model = "Unknown manufacturer";
            }

            car.Engine = new Engine()
            {
                FuelType = fuelType, HorsePowers = (horsePowers > 0 ? horsePowers : 90), Volume = (engineVolume > 0 ? engineVolume: 1.5f)
            };

            Wheel wheel = new Wheel {
                Diameter = (wheelDiameter > 0 ? wheelDiameter : 27), Manufacturer = "NOKIAN", PatternDepth = 1.5f
            };

            car.Wheels = new Wheel[] { wheel, (Wheel)wheel.Clone(), (Wheel)wheel.Clone(), (Wheel)wheel.Clone() };

            car.Carcass = new Carcass {
                CarcassType = carcassType, Width = 1.45f, Height = 1.33f, Length = 2.03f
            };

            return(car);
        }
Exemple #5
0
 /// <summary>
 /// Создать шину с заданными параметрами
 /// </summary>
 public Tire CreateTire(int profileWidth, int profileHeight, CarcassType type, int diameter) =>
 (from tire in ManufacturedTires
      where tire.ProfileWidth == profileWidth && tire.ProfileHeight == profileHeight && tire.Type == type && tire.Diameter == diameter
  select(Tire) tire.Clone())
 .FirstOrDefault();
Exemple #6
0
        private void Post_Click(object sender, EventArgs e)
        {
            //check if all necessary fields are there, and valid.
            //username

            //ReceiptNo
            if (ReceiptNo.Text == "")
            {
                MessageBox.Show("Invalid Receipt Number!");
                ReceiptNo.Focus();
            }
            if (SlapMark.Text == "")
            {
                MessageBox.Show("Invalid Slap Mark!");
                SlapMark.Focus();
            }
            if (CarcassType.Text == "")
            {
                MessageBox.Show("Invalid Carcass Type!");
                CarcassType.Focus();
            }

            if (MeatPercent.Text == "")
            {
                MessageBox.Show("Invalid Meat Percent!");
                MeatPercent.Focus();
            }

            using (SqlConnection conn = new SqlConnection(_connectionString))

            {
                CType = new string(CarcassType.Text.Take(5).ToArray());
                String q3 = "SELECT COUNT (ID) FROM [dbo].[SlaughterData] WHERE ReceiptNo ='" + ReceiptNo.Text + "'AND ItemNo ='" + CType + "'";
                using (SqlCommand cmd = new SqlCommand(q3, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error 5");
                        return;
                    }
                    try
                    {
                        Sqty = (int)cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error 6");
                        return;
                    }
                }

                conn.Close();
            }
            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                //transcoding from from carcass code to livestock code to look up in the receipt ledger


                if (CType == "G0110")
                {
                    CType = "G0101";
                }
                if (CType == "G0111")
                {
                    CType = "G0102";
                }
                if (CType == "G0113")
                {
                    CType = "G0104";
                }



                String q = "SELECT sum(convert(int, ReceivedQty) )from dbo.Receipts where ReceiptNo ='" + ReceiptNo.Text + "'AND ItemNo='" + CType + "'";
                //MessageBox.Show(q);
                using (SqlCommand cmd = new SqlCommand(q, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error7");
                        return;
                    }

                    try
                    {
                        Rqty = (int)cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error3");
                        return;
                    }
                }
                conn.Close();
            }


            if (Rqty > Sqty)
            {
                using (SqlConnection conn = new SqlConnection(_connectionString))
                {
                    string Slap  = SlapMark.Text;
                    string VNo   = VendorNo.Text;
                    string VName = VendorName.Text;
                    string MPC   = MeatPercent.Text;
                    string CCode = ClassificationCode.Text;
                    string RNo   = ReceiptNo.Text;
                    CType = new string(CarcassType.Text.Take(5).ToArray());

                    //insert the record
                    String q5 = "INSERT INTO [dbo].[SlaughterData]([SlaughterTime],[UserID],[ReceiptNo],[ItemNo],[StockWeight],[MeatPercent],[Classification Code])" +
                                "VALUES ('" + DateTime.Now + "','"
                                + User.Text + "','"
                                + RNo + "','"
                                + CType + "','"
                                + NT + "','"
                                + MPC + "','"
                                + ClassificationCode.Text + "')";
                    using (SqlCommand cmd = new SqlCommand(q5, conn))
                    {
                        try
                        {
                            conn.Open();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + "Error 8");
                            return;
                        }
                        try
                        {
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Record Posted");
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message + "Error 11");
                        }
                        conn.Close();
                    }


                    if ((Rqty - Sqty) == 1)
                    {
                        if (CType == "G0110")
                        {
                            CType = "G0101";
                        }
                        if (CType == "G0111")
                        {
                            CType = "G0102";
                        }
                        if (CType == "G0113")
                        {
                            CType = "G0104";
                        }
                        //
                        String q6 = "UPDATE [dbo].[Receipts] SET [Slaughtered]='1'  WHERE ReceiptNo='" + RNo + "'AND ItemNo ='" + CType + "'";

                        using (SqlCommand cmd = new SqlCommand(q6, conn))
                        {
                            try
                            {
                                conn.Open();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + "Error 12");
                                return;
                            }
                            try
                            {
                                cmd.ExecuteNonQuery();
                                this.initComBo();
                                ReceiptNo.Text           = "";
                                SlapMark.Text            = "";
                                ReceiptNo.SelectedText   = "";
                                SlapMark.SelectedText    = "";
                                VendorName.Text          = "";
                                VendorNo.Text            = "";
                                CarcassType.Text         = "";
                                CarcassType.SelectedText = "";
                                MeatPercent.Text         = "";
                                ClassificationCode.Text  = "";
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + "Error 10");
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("The record could not be posted. The slaughtered qty exceeds the received qty for that animal type");
                return;
            }
        }