示例#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 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();
        }
示例#3
0
        internal int GetEstimatedTimeBeforeShipping(List<ItemBike> bikesToOrder)//Maybe transfer it into Representative controller
        {
            float days = 0;
            int weeks = 0;
            int minutes = 0;
            float hours = 0;
            //updateOrderBikeList();
            SetPlanningList();
            SetBikeModelList();
            var nonPlannified = Manager.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;
        }