public ManageWorkView()
        {
            InitializeComponent();
            _viewModel = new WorkViewModel();
            var x = _viewModel.LoadData();

            view_grid.ItemsSource = x;
        }
Ejemplo n.º 2
0
        public AddWorkView()
        {
            InitializeComponent();
            _viewModel         = new WorkViewModel();
            _timeSlotViewModel = new TimeSlotViewModel();
            var x = _viewModel.LoadData();

            /*string[] days = new string[] { "Mon", "Tue", "Wed", "Thu", "Fri" };
             * //for (int i = 0; i < days.Length; i++)
             * //{
             * //    days[i] =
             * //}
             *
             *
             * //For day : - 9 ?
             * // # of days : - 5 ?
             * // TOT = 9*5 = 45
             * _timeSlotEntities = new List<TimeSlotEntity>();
             * int startTime = 8;
             * int currentDate = 0;
             * int endTime = 17;
             * for (int i = 1; i < 46; i++)
             * {
             *  if (startTime == endTime)
             *  {
             *      startTime = 8;
             *      currentDate++;
             *  }
             *
             *  _timeSlotEntities.Add(
             *      new TimeSlotEntity { ID = i, TimeSlot = $"{startTime}-{++startTime}", Day = days[currentDate] }
             *      );
             * }
             *
             * //timeSlotEntity = new TimeSlotEntity(2, "8-9", "tue");
             * //_timeSlotViewModel.SaveTimeSlotsData(timeSlotEntity);
             *
             * /*foreach (TimeSlotEntity t in _timeSlotEntities)
             * {
             *  _timeSlotViewModel.SaveTimeSlotsData(t);
             * }*/
        }
        private void edit_work_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    workId           = int.Parse(workId_txt.Text);
                string batchType        = batch_txt.Text;
                int    noOfWorkingDays  = int.Parse(working_days_no_txt.Text);
                int    noOfWorkingHours = int.Parse(working_hours_no_txt.Text);
                String startTime        = startTime_txt.Text;
                String endTime          = endTime_txt.Text;

                String monday    = "";
                String tuesday   = "";
                String wednesday = "";
                String thursday  = "";
                String friday    = "";
                String saturday  = "";
                String sunday    = "";

                int count = 0;

                //String[] days = new String[7];
                ArrayList days = new ArrayList();

                if (chk_mon.IsChecked == true)
                {
                    monday = "Monday,";
                    days.Add(monday);
                    count++;
                }
                else
                {
                    monday = null;
                }
                if (chk_tue.IsChecked == true)
                {
                    tuesday = "Tuesday,";
                    days.Add(tuesday);
                    count++;
                }
                else
                {
                    tuesday = null;
                }
                if (chk_wed.IsChecked == true)
                {
                    wednesday = "Wednesday,";
                    days.Add(wednesday);
                    count++;
                }
                else
                {
                    wednesday = null;
                }
                if (chk_thr.IsChecked == true)
                {
                    thursday = "Thursday,";
                    days.Add(thursday);
                    count++;
                }
                else
                {
                    thursday = null;
                }
                if (chk_fri.IsChecked == true)
                {
                    friday = "Friday,";
                    days.Add(friday);
                    count++;
                }
                else
                {
                    friday = null;
                }
                if (chk_sat.IsChecked == true)
                {
                    saturday = "Saturday,";
                    days.Add(saturday);
                    count++;
                }
                else
                {
                    saturday = null;
                }
                if (chk_sun.IsChecked == true)
                {
                    sunday = "Sunday";
                    days.Add(sunday);
                    count++;
                }
                else
                {
                    sunday = null;
                }

                String   workingDays = "";
                string[] array       = days.ToArray(typeof(string)) as string[];

                if (count == int.Parse(working_days_no_txt.Text))
                {
                    foreach (string value in array)
                    {
                        edit_txt_hide.AppendText(value.ToString());
                        workingDays = edit_txt_hide.Text;
                    }
                    workEntity = new WorkEntity(workId, batchType, noOfWorkingDays, workingDays, noOfWorkingHours, startTime, endTime);

                    //workEntity = CreateWorkEntity();
                    _viewModel.UpdateWorkData(workEntity);
                    view_grid.ItemsSource = _viewModel.LoadData();
                    clear();
                }
                else
                {
                    MessageBox.Show("Count of Working days and No of working days are not matching");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }