Ejemplo n.º 1
0
        private List <Schedules> GenerateScheduleList(DateTime startWeek)
        {
            List <Schedules> schedulesList = new List <Schedules>();
            int rowCount = dataGridView_home.Rows.Count;

            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
            {
                Schedules schedule = new Schedules();

                if (dataGridView_home.Rows[rowIndex].Cells[0].Value == null)
                {
                    break;
                }
                string nurserName = dataGridView_home.Rows[rowIndex].Cells[0].Value.ToString();

                schedule.ScheduledNurser = XMLHelper.GetNurserFromName(Miscellaneous.GetNurseXMLFullPath(), nurserName);
                schedule.WeekFirstDay    = startWeek.ToString("yyyy-MM-dd");
                schedule.JobsList        = new List <ScheduleJob>();

                for (int i = 1; i < 8; i++)
                {
                    string jobName_Morning   = dataGridView_home.Rows[rowIndex].Cells["M" + i].Value.ToString();
                    string jobName_Afternoon = dataGridView_home.Rows[rowIndex].Cells["A" + i].Value.ToString();

                    string jobRating_Morning   = dataGridView_home.Rows[rowIndex].Cells["M" + i].Tag == null ? "" : dataGridView_home.Rows[rowIndex].Cells["M" + i].Tag.ToString();
                    string jobRating_Afternoon = dataGridView_home.Rows[rowIndex].Cells["A" + i].Tag == null ? "" : dataGridView_home.Rows[rowIndex].Cells["A" + i].Tag.ToString();

                    ScheduleJob job = new ScheduleJob();
                    job.ScheduledWeekday = i.ToString();

                    job.Tasks = new List <TaskDetail>();
                    job.Tasks.Add(new TaskDetail()
                    {
                        JobDayType = ScheduledType.Morning.ToString(),
                        JobName    = jobName_Morning,
                        JobRating  = jobRating_Morning
                    }
                                  );
                    job.Tasks.Add(new TaskDetail()
                    {
                        JobDayType = ScheduledType.Afternoon.ToString(),
                        JobName    = jobName_Afternoon,
                        JobRating  = jobRating_Afternoon
                    });
                    schedule.JobsList.Add(job);
                }
                schedulesList.Add(schedule);
            }
            return(schedulesList);
        }
Ejemplo n.º 2
0
        void btnUploadSchedule_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd        = new OpenFileDialog();
            DateTime       dtMonthCal = monthCalendarMain.SelectionStart;
            DateTime       startWeek  = dtMonthCal.AddDays(1 - Convert.ToInt16(dtMonthCal.DayOfWeek.ToString("d")));
            List <string>  weekdays   = Miscellaneous.GenerateWeekDaysList(startWeek);

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string        fileName    = ofd.FileName.ToString();
                List <string> nursersName = XMLHelper.GetNursersName(Miscellaneous.GetNurseXMLFullPath());
                List <string> jobsName    = XMLHelper.GetJobsName(Miscellaneous.GetJobXMLFullPath());
                //只读取/处理表文件中的姓名和排班信息,如果姓名或者排班信息在系统中找不到,则抛出错误
                ExcelHelper.UploadAndSaveExcel(fileName, nursersName, jobsName);
            }
        }
Ejemplo n.º 3
0
        public static void UpdateNurses(List <Nurser> updatedNurseList)
        {
            string fullpath = Miscellaneous.GetNurseXMLFullPath();

            try
            {
                XMLHelper.DeleteXMLFile(fullpath);
                XMLHelper.CreateXmlFile(fullpath, "data", AppConfiguration.GetNurserXMLRootNode());
                XMLHelper.CreateNurseNodes(Miscellaneous.GetNurseXMLFullPath(), AppConfiguration.GetNurserXMLRootNode(), updatedNurseList);
                //AddSchedulerNodes(fullpath, updatedNurseList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private void SaveNurseAction()
        {
            string        xmlfileFullPath  = Miscellaneous.GetNurseXMLFullPath();
            int           rowCount         = nurseGrid.RowCount;
            List <Nurser> updatedNurseList = new List <Nurser>();

            for (int index = 0; index < rowCount - 1; index++)
            {
                string nurseName   = nurseGrid.Rows[index].Cells[0].Value.ToString();
                string nurseLevel  = nurseGrid.Rows[index].Cells[1].Value.ToString();
                string nurseRating = nurseGrid.Rows[index].Cells[2].Value.ToString();
                string id          = nurseGrid.Rows[index].Cells[3].Value.ToString();

                updatedNurseList.Add(new Nurser()
                {
                    Id = id, NurserLevel = nurseLevel, NurserName = nurseName, NurserLevelRating = nurseRating
                });


                //if (!string.IsNullOrEmpty(nurseName))
                //{
                //    Nurser nurser = new Nurser();
                //    nurser.NurserName = nurseName;
                //    nurser.NurserLevel = nurseLevel;
                //    nurser.NurserLevelRating = nurseRating;
                //    //it's a new row if empty
                //    if (string.IsNullOrEmpty(id))
                //    {
                //        DataInit.AddNurseNode(xmlfileFullPath, nurser);
                //    }
                //    else
                //    {
                //        nurser.Id = id;
                //        DataInit.UpdateNurserNode(xmlfileFullPath, nurser);
                //    }
                //}
            }
            DataInit.UpdateNurses(updatedNurseList);
            InitScheduleGridComponet("");
            MessageBox.Show("保存成功。");
        }