예제 #1
0
        private void addToPlanifiedBikes(object sender, DataGridViewCellEventArgs e)
        {
            BikeModel model = newApp.bikeModels.FirstOrDefault(x => x.color == dataGridView2.Rows[e.RowIndex].Cells[5].Value.ToString() && x.size == Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[4].Value.ToString()) && x.type == dataGridView2.Rows[e.RowIndex].Cells[3].Value.ToString()); //gets the specific model
            Bike      bike  = new Bike(Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString()), model);                                                                                                                                                                              //Needs to be verified (id)

            user.AddToPlanningCart(bike, Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString()));
            // NEED TO MODIFY THE DATAGRIDVIEW AND THE NON PLANNIFIEDBIKES
            string weekName = textBox1.Text;

            if (weekName == string.Empty)
            {
                message = "Choose the week ID from the calendar ! ";
                MessageBox.Show(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                dataGridView1.Rows.Add();
                List <string> reset = new List <string>();
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0].Value = dataGridView2.Rows[e.RowIndex].Cells[0].Value; //id bike
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value = dataGridView2.Rows[e.RowIndex].Cells[1].Value; //type
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value = dataGridView2.Rows[e.RowIndex].Cells[2].Value; //size
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value = dataGridView2.Rows[e.RowIndex].Cells[3].Value; //color
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[4].Value = dataGridView2.Rows[e.RowIndex].Cells[4].Value; //status
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[5].Value = dataGridView2.Rows[e.RowIndex].Cells[5].Value;
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[6].Value = dataGridView2.Rows[e.RowIndex].Cells[6].Value;
                foreach (var nonPlanifiedOrderDetails in Manager.GetNonPlanifiedBikes())
                {
                    dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[7].Value = nonPlanifiedOrderDetails[5]; // status (new ...)state of building
                }
                dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[8].Value = weekName;                        //plannified week
                dataGridView2.Rows.RemoveAt(dataGridView2.CurrentRow.Index);
            }
        }
예제 #2
0
        private void setBikesToBuild(List <List <string> > bikeDetails, List <BikeModel> bikeModels, List <List <string> > planningDetails)
        {
            foreach (var elem in bikeDetails)
            {
                int    idOrderDetails = Int32.Parse(elem[0]);
                string bikeType       = elem[1];
                int    bikeSize       = Int32.Parse(elem[2]);
                string bikeColor      = elem[3];
                string status         = elem[5];
                //string assemblerName = assemblerNames.FirstOrDefault(x => Int32.Parse(x.Key) == idOrderDetails).Value;
                int    findIndex     = planningDetails.FindIndex(x => Int32.Parse(x[1]) == idOrderDetails);
                string assemblerName = planningDetails[findIndex][2];
                string startDate     = planningDetails[findIndex][3];
                string endDate       = planningDetails[findIndex][4];
                //takes Corresponding model, creates a bike, adds a status and assembler's name, adds bike to the list
                BikeModel model   = bikeModels.FirstOrDefault(x => x.Color == bikeColor && x.Size == bikeSize && x.Type == bikeType);//gets the specific model
                var       newBike = new Bike(idOrderDetails, model)
                {
                    assembler = assemblerName, startBuildTime = startDate, endBuildTime = endDate
                };
                newBike.setNewState(status);
                bikesToBuild.Add(newBike);


                workingMinute += newBike.TotalTime;
            }
        }
예제 #3
0
        private void Manager_Make_Planning_Load(object sender, EventArgs e)
        {
            int i = 0;
            int t = 0;

            dataGridView2.Rows.Clear();
            //Console.WriteLine("détails in manager plan : " + newApp.getPlanifiedBikes().Count);

            string clientName    = "";
            string previousOrder = "";

            foreach (var nonPlanifiedOrderDetails in Manager.GetNonPlanifiedBikes())
            {
                BikeModel model   = newApp.bikeModels.FirstOrDefault(x => x.color == nonPlanifiedOrderDetails[3] && x.size == Int32.Parse(nonPlanifiedOrderDetails[2]) && x.type == nonPlanifiedOrderDetails[1]);//gets the specific model
                Bike      newBike = new Bike(Int32.Parse(nonPlanifiedOrderDetails[0]), model);
                t += newBike.totalTime;
                dataGridView2.Rows.Add();

                dataGridView2.Rows[i].Cells[1].Value = nonPlanifiedOrderDetails[6];  //id order
                dataGridView2.Rows[i].Cells[2].Value = nonPlanifiedOrderDetails[0];  //id bike
                dataGridView2.Rows[i].Cells[3].Value = nonPlanifiedOrderDetails[1];  //type
                dataGridView2.Rows[i].Cells[4].Value = nonPlanifiedOrderDetails[2];  //size
                dataGridView2.Rows[i].Cells[5].Value = nonPlanifiedOrderDetails[3];  //color
                dataGridView2.Rows[i].Cells[6].Value = newBike.totalTime.ToString(); // time

                if (nonPlanifiedOrderDetails[6] != previousOrder)
                {
                    clientName    = Manager.GetClientName(Int32.Parse(nonPlanifiedOrderDetails[6]));
                    previousOrder = nonPlanifiedOrderDetails[6];
                }
                dataGridView2.Rows[i].Cells[0].Value = clientName;//client
                i++;
            }
            labelTime.Text = t.ToString() + " / " + (120 * 60).ToString();
        }
예제 #4
0
        public Bike(int bikeId, BikeModel bikeModel) //ID OF THE BIKE NOT BIKEMODEL
        {
            this.bikeId = bikeId;
            _model      = bikeModel;

            type      = _model.type;
            color     = _model.color;
            size      = _model.size;
            price     = _model.price;
            totalTime = _model.totalTime;
            bikeParts = _model.bikeParts;
        }
예제 #5
0
        private void setBikeList(List <BikeModel> bikeModels, List <List <string> > orderDetail)
        {
            foreach (var elem in orderDetail)
            {
                int    id    = Int32.Parse(elem[0]);
                string type  = elem[1];
                int    size  = Int32.Parse(elem[2]);
                string color = elem[3];
                //int price = Int32.Parse(elem[4]);

                BikeModel model = bikeModels.FirstOrDefault(x => x.Color == color && x.Size == size && x.Type == type);//gets the specific model
                Bike      bike  = new Bike(id, model);
                bike.setNewState(elem[5]);
                bikeList.Add(bike); //adds a corresponding Bike
            }
        }
예제 #6
0
        private void Manager_Make_Planning_Load(object sender, EventArgs e)
        {
            int i = 0;
            int t = 0;

            Console.WriteLine("détails in manager plan : " + newApp.getPlanifiedBikes().Count);
            foreach (var planifiedOrderDetails in newApp.getPlanifiedBikes())
            {
                //Console.WriteLine("détails in manager plan : " + orderDetails.Count);
                Console.WriteLine(planifiedOrderDetails[0] + "|" + planifiedOrderDetails[1] + "|" + planifiedOrderDetails[2] + "|" + planifiedOrderDetails[3] + "|" + planifiedOrderDetails[4] + "|" + planifiedOrderDetails[5] + "|" + planifiedOrderDetails[6] + "|" + planifiedOrderDetails[7] + "|" + planifiedOrderDetails[8]);
                BikeModel model   = newApp.bikeModels.FirstOrDefault(x => x.Color == planifiedOrderDetails[3] && x.Size == Int32.Parse(planifiedOrderDetails[2]) && x.Type == planifiedOrderDetails[1]);//gets the specific model
                Bike      newBike = new Bike(Int32.Parse(planifiedOrderDetails[0]), model);
                t += newBike.TotalTime;

                dataGridView1.Rows.Add();
                dataGridView1.Rows[i].Cells[0].Value = planifiedOrderDetails[0]; //id order details
                dataGridView1.Rows[i].Cells[1].Value = planifiedOrderDetails[1]; //type
                dataGridView1.Rows[i].Cells[2].Value = planifiedOrderDetails[2]; //size
                dataGridView1.Rows[i].Cells[3].Value = planifiedOrderDetails[3]; //color
                dataGridView1.Rows[i].Cells[4].Value = planifiedOrderDetails[5]; //status
                dataGridView1.Rows[i].Cells[5].Value = planifiedOrderDetails[7]; //plannified week
                dataGridView1.Rows[i].Cells[6].Value = planifiedOrderDetails[8]; //Id Order
                dataGridView1.Rows[i].Cells[7].Value = newBike.TotalTime.ToString();
                i++;
            }

            /* Console.WriteLine("index i : " + i);
             * Console.WriteLine("Count  : " + newApp.getNonPlanifiedBikes().Count);*/
            i = 0;
            foreach (var nonPlanifiedOrderDetails in newApp.getNonPlanifiedBikes())
            {
                BikeModel model   = newApp.bikeModels.FirstOrDefault(x => x.Color == nonPlanifiedOrderDetails[3] && x.Size == Int32.Parse(nonPlanifiedOrderDetails[2]) && x.Type == nonPlanifiedOrderDetails[1]);//gets the specific model
                Bike      newBike = new Bike(Int32.Parse(nonPlanifiedOrderDetails[0]), model);
                t += newBike.TotalTime;
                dataGridView2.Rows.Add();
                dataGridView2.Rows[i].Cells[0].Value = nonPlanifiedOrderDetails[0]; //id order details
                dataGridView2.Rows[i].Cells[1].Value = nonPlanifiedOrderDetails[1]; //type
                dataGridView2.Rows[i].Cells[2].Value = nonPlanifiedOrderDetails[2]; //size
                dataGridView2.Rows[i].Cells[3].Value = nonPlanifiedOrderDetails[3]; //color
                dataGridView2.Rows[i].Cells[4].Value = nonPlanifiedOrderDetails[5]; //status
                dataGridView2.Rows[i].Cells[5].Value = nonPlanifiedOrderDetails[6]; //Id Order
                dataGridView2.Rows[i].Cells[6].Value = newBike.TotalTime.ToString();

                i++;
            }
            labelTime.Text = t.ToString() + " / " + (120 * 60).ToString();
        }
예제 #7
0
        public Bike(int bikeId, BikeModel bikeModel) //ID OF THE BIKE NOT BIKEMODEL
        {
            this.bikeId = bikeId;
            _model      = bikeModel;

            /*this.Type = Type;
             * this.Size = Size;
             * this.Color = Color;*/
            //call app to get the model of the bike


            /*App newApp = new App();
             * var bikeModels = newApp.getBikeModelList();
             * _model = bikeModels.FirstOrDefault(x => x.Color == Color && x.Size == Size && x.Type == Type);*/

            Type      = _model.Type;
            Color     = _model.Color;
            Size      = _model.Size;
            Price     = _model.Price;
            TotalTime = _model.TotalTime;
            bikeParts = _model.bikeParts;
        }
예제 #8
0
        private void button9_Click(object sender, EventArgs e)//Load bikeParts
        {
            dataGridView2.Rows.Clear();
            app.SetBikePartList();
            var       parts = app.bikePartList;
            int       i     = 0;
            int       idModel;
            BikeModel model = new BikeModel(null, null, 0);

            if (comboBox1.Text != "")
            {
                idModel = Int32.Parse(comboBox1.Text);
                model   = app.bikeModels.FirstOrDefault(x => x.idBikeModel == idModel);
            }


            foreach (var part in parts)
            {
                int    id    = part.part_Id;
                int    price = part.price;
                string name  = part.name;
                dataGridView2.Rows.Add();
                dataGridView2.Rows[i].Cells[0].Value = id;
                dataGridView2.Rows[i].Cells[1].Value = name;
                dataGridView2.Rows[i].Cells[2].Value = price;
                if (model.bikeParts != null)
                {
                    dataGridView2.Rows[i].Cells[3].Value = model.bikeParts.Count(x => x.part_Id == id).ToString();
                }
                else
                {
                    dataGridView2.Rows[i].Cells[3].Value = "0";
                }
                dataGridView2.Rows[i].Cells[4].Value = "0";

                i++;
            }
        }
예제 #9
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            BikeModel model = newApp.bikeModels.FirstOrDefault(x => x.Color == dataGridView2.Rows[e.RowIndex].Cells[3].Value.ToString() && x.Size == Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString()) && x.Type == dataGridView2.Rows[e.RowIndex].Cells[1].Value.ToString()); //gets the specific model
            Bike      bike  = new Bike(Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString()), model);                                                                                                                                                                              //Needs to be verified (id)

            user.addToPlanningCart(bike, Int32.Parse(dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString()));
            // NEED TO MODIFY THE DATAGRIDVIEW AND THE NON PLANNIFIEDBIKES

            string weekName = textBox1.Text;

            dataGridView1.Rows.Add();
            List <string> reset = new List <string>();

            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0].Value = dataGridView2.Rows[e.RowIndex].Cells[0].Value; //id order details
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value = dataGridView2.Rows[e.RowIndex].Cells[1].Value; //type
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value = dataGridView2.Rows[e.RowIndex].Cells[2].Value; //size
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value = dataGridView2.Rows[e.RowIndex].Cells[3].Value; //color
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[4].Value = dataGridView2.Rows[e.RowIndex].Cells[4].Value; //status
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[5].Value = weekName;                                      //plannified week
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[6].Value = dataGridView2.Rows[e.RowIndex].Cells[5].Value;
            dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[7].Value = dataGridView2.Rows[e.RowIndex].Cells[6].Value;
            dataGridView2.Rows.RemoveAt(dataGridView2.CurrentRow.Index);
        }
예제 #10
0
        internal List<BikeModel> getBikeModelList() //is used to get all bike models
        {
            List<BikeModel> bikeList = new List<BikeModel>();//list to return
            List<List<string>> modelList = getFromDB("Bike_Model");//bikemodels from db
            if(_linkingPartList.Count == 0)
            {
                updateLinkingPartList();
            }
            if(bikePartList.Count == 0)
            {
                updateBikePartList();
            }
            foreach (var row in modelList)
            {
                List<int> bikePartsIds = new List<int>();
                int id = Int32.Parse(row[0]);
                string color = row[1];
                int size = Int32.Parse(row[2]);
                string type = row[3];
                var newBikeModel = new BikeModel(type, color, size) { idBikeModel = id };

                foreach (var part in _linkingPartList)
                {
                    if (Int32.Parse(part[1]) == id)
                    {
                        bikePartsIds.Add(Int32.Parse(part[0]));
                    }
                }
                bikePartsIds.Sort();
                newBikeModel.bikeParts = bikePartsIds.Select(x => bikePartList.First(part => part.part_Id == x)).ToList(); //FOR DUPLICATES 
                //newBikeModel.bikeParts = bikePartList.FindAll(part => bikePartsIds.Contains(part.part_Id));
                newBikeModel.setPriceAndTime();
                bikeList.Add(newBikeModel);
            }
            return bikeList;
        }
예제 #11
0
        internal int getEstimatedTimeBeforeShipping(List<ItemBike> bikesToOrder)//WORKING ON IT
        {
            float days = 0;
            int weeks = 0;
            int minutes = 0;
            float hours = 0;
            //updateOrderBikeList();
            updatePlanningList();
            updateBikeModelList();
            var nonPlannified = getNonPlanifiedBikes();
            var nonPlannifiedBikes = new List<Bike>();
            //var order = orderBikeList.FirstOrDefault(x => x.orderId == orderId);
            foreach(var bike in nonPlannified)
            {
                BikeModel model = bikeModels.FirstOrDefault(x => x.Color == bike[3] && x.Size == Int32.Parse(bike[2]) && x.Type == bike[1]);//gets the specific model
                nonPlannifiedBikes.Add(new Bike(Int32.Parse(bike[0]), model));//adds a corresponding Bike
            }
            foreach(var bike in nonPlannifiedBikes)
            {
                minutes += bike.TotalTime;
            }
            foreach(var elem in bikesToOrder)
            {
                minutes += elem.getTotalTime();
            }
            hours = minutes/ 60;
            days = hours / 24; //because 3 builders working 8 hours a day

            if (planningList.Count != 0)
            {
                string lastWeek = planningList.Last().weekName;
                string b = string.Empty;
                int lastWeekNumber=0;

                CultureInfo myCI = new CultureInfo("en-US");
                Calendar myCal = myCI.Calendar;
                CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
                DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
                var currentWeek = myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW);//gets the current week
                for (int i = 0; i < lastWeek.Length; i++)
                {
                    if (Char.IsDigit(lastWeek[i]))
                        b += lastWeek[i];
                }
                if (b.Length > 0)
                {
                    lastWeekNumber = int.Parse(b);
                }
                weeks = lastWeekNumber - currentWeek ;
                Console.WriteLine("CURRENT WEEK : " + currentWeek);
                Console.WriteLine("LAST PLANNED WEEK : " + lastWeekNumber + "LAST WEEK NAME : "+lastWeek);
                Console.WriteLine("DIFFERENCE : " + weeks);


            }
            weeks += (int)(Math.Ceiling(days) / 5) +1;
            Console.WriteLine("MINUTES " + minutes+ " HOURS " + hours + " DAYS " + days);
            Console.WriteLine("DIFFERENCE + NEW BIKES TO BUILD: " + weeks);

            return weeks;
        }
예제 #12
0
        private void loadPlanifiedBikes()
        {
            int i = 0;
            int j = 0;
            int t = 0;

            dataGridView1.Rows.Clear();
            TimeSpan totalTime      = new TimeSpan();
            string   clientName1    = "";
            string   previousOrder1 = "";

            foreach (var planifiedOrderDetails in Manager.GetPlanifiedBikes())
            {
                //Console.WriteLine("détails in manager plan : " + orderDetails.Count);
                Console.WriteLine(planifiedOrderDetails[0] + "|" + planifiedOrderDetails[1] + "|" + planifiedOrderDetails[2] + "|" + planifiedOrderDetails[3] + "|" + planifiedOrderDetails[4] + "|" + planifiedOrderDetails[5] + "|" + planifiedOrderDetails[6] + "|" + planifiedOrderDetails[7] + "|" + planifiedOrderDetails[8]);
                BikeModel model   = newApp.bikeModels.FirstOrDefault(x => x.color == planifiedOrderDetails[3] && x.size == Int32.Parse(planifiedOrderDetails[2]) && x.type == planifiedOrderDetails[1]);//gets the specific model
                Bike      newBike = new Bike(Int32.Parse(planifiedOrderDetails[0]), model);
                t += newBike.totalTime;
                if (updateButton == true && newWeekToAssign.Text != string.Empty)
                {
                    if (planifiedOrderDetails[7] == newWeekToAssign.Text.ToString() && planifiedOrderDetails[5] != "Closed")
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1.Rows[j].Cells[0].Value = Manager.GetClientName(Int32.Parse(planifiedOrderDetails[6]));
                        dataGridView1.Rows[j].Cells[1].Value = planifiedOrderDetails[6]; //Id Order
                        dataGridView1.Rows[j].Cells[2].Value = planifiedOrderDetails[0]; //id bike
                        dataGridView1.Rows[j].Cells[3].Value = planifiedOrderDetails[1]; //type
                        dataGridView1.Rows[j].Cells[4].Value = planifiedOrderDetails[2]; //size
                        dataGridView1.Rows[j].Cells[5].Value = planifiedOrderDetails[3]; //color
                        dataGridView1.Rows[j].Cells[6].Value = newBike.totalTime.ToString();
                        dataGridView1.Rows[j].Cells[7].Value = planifiedOrderDetails[5]; //status
                        dataGridView1.Rows[j].Cells[8].Value = planifiedOrderDetails[7]; //plannified week
                        j++;
                    }
                }
                else if (planifiedOrderDetails[7] == comboBox1.Text.ToString())
                {
                    if (planifiedOrderDetails[5] != "Closed")
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1.Rows[i].Cells[1].Value = planifiedOrderDetails[6]; //Id Order
                        dataGridView1.Rows[i].Cells[2].Value = planifiedOrderDetails[0]; //id bike
                        dataGridView1.Rows[i].Cells[3].Value = planifiedOrderDetails[1]; //type
                        dataGridView1.Rows[i].Cells[4].Value = planifiedOrderDetails[2]; //size
                        dataGridView1.Rows[i].Cells[5].Value = planifiedOrderDetails[3]; //color
                        dataGridView1.Rows[i].Cells[6].Value = newBike.totalTime.ToString();
                        dataGridView1.Rows[i].Cells[7].Value = planifiedOrderDetails[5]; //status
                        dataGridView1.Rows[i].Cells[8].Value = planifiedOrderDetails[7]; //plannified week
                        if (planifiedOrderDetails[7] == comboBox1.Text.ToString() && planifiedOrderDetails[6] != previousOrder1)
                        {
                            clientName1    = Manager.GetClientName(Int32.Parse(planifiedOrderDetails[6]));
                            previousOrder1 = planifiedOrderDetails[6];
                        }

                        dataGridView1.Rows[i].Cells[0].Value = clientName1;//client
                        TimeSpan toAdd = new TimeSpan(0, newBike.totalTime, 0);
                        totalTime += toAdd;
                        i++;
                    }
                }
            }
            computeTime(totalTime);
        }