Ejemplo n.º 1
0
        private void SaveJobAction()
        {
            DataTable  souceJobData = null;
            DataTable  gridJobData  = null;
            List <Job> jobs         = null;

            try
            {
                int    rowCount           = jobGridView.RowCount;
                string jobxmlfileFullPath = Miscellaneous.GetJobXMLFullPath();
                //MessageBox.Show(jobxmlfileFullPath);
                souceJobData = XMLHelper.GetJobsDataTable();
                gridJobData  = DatagridviewHelper.ConvertDataGridViewToTable(jobGridView);

                bool isSame = DatagridviewHelper.CompareDataTable(souceJobData, gridJobData, "JobName");

                if (!isSame)
                {
                    jobs = DataInit.CovertJobTableToLists(gridJobData);
                    XMLHelper.UpdateJobNodes(jobxmlfileFullPath, jobs);

                    //for (int index = 0; index < rowCount - 1; index++)
                    //{
                    //    string jobTitle = jobGridView.Rows[index].Cells[0].Value.ToString();
                    //    string jobRating = jobGridView.Rows[index].Cells[1].Value.ToString();
                    //    string id = jobGridView.Rows[index].Cells[2].Value.ToString();
                    //    if (!string.IsNullOrEmpty(jobTitle) && !string.IsNullOrEmpty(jobRating))
                    //    {
                    //        Job job = new Job();
                    //        job.JobName = jobTitle;
                    //        job.JobIndex = jobRating;
                    //        //it's a new row if empty
                    //        if (string.IsNullOrEmpty(id))
                    //        {
                    //            DataInit.AddJobNode(jobxmlfileFullPath, job);
                    //        }
                    //        else
                    //        {
                    //            job.Id = id;
                    //            DataInit.UpdateJobNode(jobxmlfileFullPath, "Jobs", job);
                    //        }
                    //    }
                    //    else
                    //    {
                    //        MessageBox.Show("岗位名称或者岗位系数不能为空", "保存失败");
                    //    }

                    //}
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据保存错误:" + ex.Message, "系统错误提示");
            }
            finally {
                souceJobData = null;
                gridJobData  = null;
                jobs         = null;
            }
        }
Ejemplo n.º 2
0
        private void UpdateScheduleJobDrop()
        {
            //if (!_monthPickerSelected)
            //{ //用户还没有选择排版日期,即排班计划还没有生成
            //    BindHomeJobDrop();
            //}
            Control[] jobBox = dataGridView_home.Controls.Find("jobBox", false);

            List <Job> jobs   = XMLHelper.GetJobs(Miscellaneous.GetJobXMLFullPath());
            DataTable  dtJobs = new DataTable();

            dtJobs.Columns.Add("Id");
            dtJobs.Columns.Add("Name");

            foreach (Job item in jobs)
            {
                DataRow nameRow = dtJobs.NewRow();

                //ComboBoxItem boxItem = new ComboBoxItem(item.JobIndex, item.JobName);
                nameRow["Id"]   = item.JobIndex;
                nameRow["Name"] = item.JobName;
                dtJobs.Rows.Add(nameRow);
            }
            ComboBox cmb_temp = jobBox[0] as ComboBox;

            cmb_temp.ValueMember   = "Id";
            cmb_temp.DisplayMember = "Name";
            cmb_temp.DropDownStyle = ComboBoxStyle.DropDownList;
            cmb_temp.DataSource    = dtJobs;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成排班信息中的排班下拉项
        /// </summary>
        private void BindHomeJobDrop()
        {
            List <Job> jobs = XMLHelper.GetJobs(Miscellaneous.GetJobXMLFullPath());
            //List<String> nursers = XMLHelper.GetNursersName(GetNurseXMLFullPath());
            DataTable dtJobs = new DataTable();

            dtJobs.Columns.Add("Id");
            dtJobs.Columns.Add("Name");
            ComboBox cmb_temp = new ComboBox();

            foreach (Job item in jobs)
            {
                DataRow nameRow = dtJobs.NewRow();

                //ComboBoxItem boxItem = new ComboBoxItem(item.JobIndex, item.JobName);
                nameRow["Id"]   = item.JobIndex;
                nameRow["Name"] = item.JobName;
                dtJobs.Rows.Add(nameRow);
            }
            cmb_temp.ValueMember   = "Id";
            cmb_temp.Name          = "jobBox";
            cmb_temp.DisplayMember = "Name";
            cmb_temp.DropDownStyle = ComboBoxStyle.DropDownList;
            cmb_temp.Visible       = false;
            cmb_temp.DataSource    = dtJobs;

            dataGridView_home.Controls.Add(cmb_temp);

            cmb_temp.SelectedIndexChanged += new EventHandler(cmb_Job_SelectedIndexChanged);
        }
Ejemplo n.º 4
0
        private BindingSource DataBindingJobsSource()
        {
            System.Data.DataSet ds = new System.Data.DataSet();
            string xmlfileFullPath = Miscellaneous.GetJobXMLFullPath();

            //string rootElement = "Jobs";
            ds.ReadXml(xmlfileFullPath);

            return(new BindingSource(ds.Tables[0], null));
        }
Ejemplo n.º 5
0
        private DataTable InitReporingForJobs()
        {
            List <string> jobsName = XMLHelper.GetJobsName(Miscellaneous.GetJobXMLFullPath());
            DataTable     dt       = new DataTable();

            dt.Columns.Add("姓名");
            foreach (var item in jobsName)
            {
                dt.Columns.Add(item);
            }
            return(dt);
        }
Ejemplo n.º 6
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);
            }
        }