private void paintRow(DataGridViewRow ADataGridViewRow)
 {
     if (ADataGridViewRow != null)
     {
         // Получаем строку в первом наборе данных
         EmployeeInSchoolYear eiw = (EmployeeInSchoolYear)ADataGridViewRow.DataBoundItem;
         if (eiw != null)
         {
             DataGridViewCellStyle newStyle = dataGridViewEmployeeInSchoolYear.DefaultCellStyle.Clone();
             if (eiw.IsOverload)
             {
                 newStyle.BackColor = Color.LightCoral;
             }
             else if (eiw.IsUnderload)
             {
                 newStyle.BackColor = Color.LightGray;
             }
             else if (eiw.IsPochFondOverload)
             {
                 newStyle.BackColor = Color.Red;
             }
             else
             {
                 newStyle.BackColor = Color.White;
             }
             ADataGridViewRow.DefaultCellStyle = newStyle;
         }
     }
 }
        private void dataGridViewEmployeeInSchoolYear_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            EmployeeInSchoolYear         eisy   = (EmployeeInSchoolYear)bindingSourceEmployeeInSchoolYear.Current;
            FormEmployeeInSchoolYearEdit feisye = new FormEmployeeInSchoolYearEdit(eisy, myDatabase);

            feisye.ShowDialog();
            updatedataGridViewEmployeeInSchoolYear();
        }
        private void buttonGoToFormalEmployee_Click(object sender, EventArgs e)
        {
            CourseInWork                 ciw    = (CourseInWork)bindingSourceFact.Current;
            EmployeeInSchoolYear         eisy   = new EmployeeInSchoolYear(ciw.Twin.Employee, ciw.SchoolYear);
            FormEmployeeInSchoolYearEdit feisye = new FormEmployeeInSchoolYearEdit(eisy, myDatabase);

            feisye.ShowDialog();
            updateParameters();
            updateDataGridViews();
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            EmployeeInSchoolYear eisy = (EmployeeInSchoolYear)bindingSourceEmployeeInSchoolYear.Current;

            if (eisy != null)
            {
                File.WriteAllText("Employee.txt",
                                  eisy.GetEmployeeInfo(myDatabase.CourseInWork.ToList <CourseInWork>()),
                                  Encoding.Default);
                // MessageBox.Show(eisy.GetEmployeeInfo());
                FormEditor fe = new FormEditor(eisy.GetEmployeeInfo(myDatabase.CourseInWork.ToList <CourseInWork>()));
                fe.ShowDialog();
            }
        }
        private void FormEmployeeInSchoolYear_Load(object sender, EventArgs e)
        {
            DataLoadOptions dlo = new DataLoadOptions();

            dlo.LoadWith <CourseInWork>(ciw => ciw.Employee);
            dlo.LoadWith <CourseInWork>(ciw => ciw.SchoolYear);
            myDatabase.LoadOptions = dlo;

            SchoolYear firstSchoolYear = myDatabase.SchoolYear.FirstOrDefault(sy => sy.ID == iCathedra_Settings.SchoolYearId);

            #region Заполняем список dataGridViewEmployeeInSchoolYear
            foreach (Employee em in myDatabase.Employee)
            {
                if (!em.NonActive)
                {
                    EmployeeInSchoolYear eiw = new EmployeeInSchoolYear(em, firstSchoolYear);
                    entitySetEmployeeInSchoolYear.Add(eiw);
                }
            }
            bindingSourceEmployeeInSchoolYear.DataSource = entitySetEmployeeInSchoolYear;
            #endregion

            bindingSourceEmployee.DataSource = myDatabase.Employee;

            #region Вид нагрузки
            Dictionary <System.Nullable <short>, string> workload = new Dictionary <System.Nullable <short>, string>();
            foreach (WorkloadType wt in Enum.GetValues(typeof(WorkloadType)))
            {
                workload.Add((System.Nullable <short>)wt, wt.ToString().Replace('_', ' '));
            }

            BindingSource workloadBindingSource = new BindingSource();
            workloadBindingSource.DataSource = workload;
            #endregion


            updatedataGridViewEmployeeInSchoolYear();

            this.WindowState = FormWindowState.Maximized;
        }
        private void updateParameters()
        {
            //labelTotalFormalWorkloadValue.Text = (eisy.Post.RateInHoursInSchoolYear(eisy.SchoolYear)*
            //    eisy.RateForm).ToString();
            labelTotalFormalWorkloadValue.Text = eisy.RateInHours.ToString();

            labelFactPochFondText.Text = " - в т.ч. почасовой фонд (лимит " + eisy.PochFondLimit.ToString() + "):";

            Employee             pf     = myDatabase.Employee.FirstOrDefault(p => p.Id == iCathedra_Settings.PochFondKod);
            EmployeeInSchoolYear eisypf = new EmployeeInSchoolYear(pf, eisy.SchoolYear);

            labelPochNagruzValue.Text = String.Format("{0}/{1}/{2}",
                                                      eisypf.Post.RateInHoursInSchoolYear(eisypf.SchoolYear),
                                                      eisypf.WorkloadForm,
                                                      eisypf.Post.RateInHoursInSchoolYear(eisypf.SchoolYear) - eisypf.WorkloadForm);

            labelFormalWorkloadValue.Text = eisy.WorkloadForm.ToString();
            if (eisy.IsOverload || eisy.IsUnderload)
            {
                labelFormalWorkloadValue.BackColor = Color.LightCoral;
            }
            else
            {
                labelFormalWorkloadValue.BackColor = Color.LightGreen;
            }

            labelUnderloadValue.Text = eisy.Underload.ToString();
            if (eisy.IsUnderload)
            {
                labelUnderloadValue.BackColor = Color.LightCoral;
            }
            else if (eisy.Underload == 0)
            {
                labelUnderloadValue.BackColor = this.BackColor;
            }
            else
            {
                labelUnderloadValue.BackColor = Color.LightGreen;
            }

            labelOverloadValue.Text = eisy.Overload.ToString();
            if (eisy.IsOverload)
            {
                labelOverloadValue.BackColor = Color.LightCoral;
            }
            else if (eisy.Overload == 0)
            {
                labelOverloadValue.BackColor = this.BackColor;
            }
            else
            {
                labelOverloadValue.BackColor = Color.LightGreen;
            }

            labelFactValue.Text = eisy.WorkloadFact.ToString();

            labelFactOtherTutorValue.Text = eisy.WorkloadFactTutor.ToString();

            labelFactPochFondValue.Text = eisy.WorkloadFactPochFond.ToString();
            if (eisy.IsPochFondOverload)
            {
                labelFactPochFondValue.BackColor = Color.LightCoral;
            }
        }
 public FormEmployeeInSchoolYearEdit(EmployeeInSchoolYear Aeisy, Database AmyDatabase)
 {
     InitializeComponent();
     eisy       = Aeisy;
     myDatabase = AmyDatabase;
 }
Esempio n. 8
0
        private void данныеДляРасчетаВыплатМеждуПреподавателямиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Database             myDatabase = new Database("Database.sdf");
            FormSelectSchoolYear fssy       = new FormSelectSchoolYear();

            fssy.ShowDialog();
            if (fssy.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                List <string> ls = new List <string>();
                ls.Add("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
                ls.Add("<html>");
                ls.Add(" <head>");
                ls.Add("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">");
                ls.Add("  <title>Данные для выплат компенсаций</title>");
                ls.Add(" </head>");
                ls.Add(" <body>");
                ls.Add("<h1 align=\"center\">Данные для выплат компенсаций</h1>");
                string s = String.Format("учебной нагрузки для заочников на {0} учебного года", fssy.SelectedSchoolYear.Years);
                ls.Add("<p align=\"center\">" + s + "</p>");
                ls.Add("<table border=\"1\">");
                ls.Add("<thead>");
                ls.Add("<tr>");
                ls.Add("<td><b>Преподаватель</b></td>");
                ls.Add("<td><b>Объем формальной нагрузки</b></td>");
                ls.Add("<td><b>Нагрузка всего</b></td>");
                ls.Add("<td><b>Доля формальной нагрузки (%)</b></td>");
                ls.Add("<td><b>Ежемесячные выплаты чистыми</b></td>");
                ls.Add("<td><b>Сумма ежемесячной компенсации</b></td>");
                ls.Add("</tr>");
                ls.Add("<tr>");
                ls.Add("<td align=\"center\">1</td>");
                ls.Add("<td align=\"center\">2</td>");
                ls.Add("<td align=\"center\">3</td>");
                ls.Add("<td align=\"center\">4</td>");
                ls.Add("<td align=\"center\">5</td>");
                ls.Add("<td align=\"center\">6</td>");
                ls.Add("</tr>");
                ls.Add("</thead>");
                ls.Add("<tbody>");
                foreach (Employee ee in myDatabase.Employee)
                {
                    EmployeeInSchoolYear           eisy = new EmployeeInSchoolYear(ee, fssy.SelectedSchoolYear);
                    Dictionary <Employee, decimal> d    = eisy.SplitByFormalEmployee(myDatabase.CourseInWork.ToList <CourseInWork>());
                    if (d.Count > 0)
                    {
                        ls.Add("<tr><td colspan=\"6\"><h3>" + ee.ToString() + "</h3></td></tr>");
                        foreach (KeyValuePair <Employee, decimal> kvp in d)
                        {
                            EmployeeInSchoolYear associtedEmployee = new EmployeeInSchoolYear(kvp.Key, fssy.SelectedSchoolYear);
                            decimal totalformworkload = associtedEmployee.WorkloadForm;

                            ls.Add("<tr align=\"center\">");
                            ls.Add(String.Format("<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td>",
                                                 kvp.Key.ToString(),
                                                 kvp.Value,
                                                 totalformworkload,
                                                 Math.Round(kvp.Value * 100 / totalformworkload, 2),
                                                 associtedEmployee.Salary,
                                                 Math.Round(kvp.Value * associtedEmployee.Salary / totalformworkload, 2)
                                                 ));
                            ls.Add("</tr>");
                        }
                    }
                }
                ls.Add("</tbody>");
                ls.Add("</table>");
                ls.Add("</body>");
                File.WriteAllLines("CrossPay.html", ls.ToArray(), Encoding.GetEncoding(1251));
                Process.Start("CrossPay.html");

                //var q = from ciw in myDatabase.CourseInWork
                //        where ciw.SchoolYearID == fssy.SelectedSchoolYear.ID
                //        orderby ciw.EmployeeID, ciw.CourseID
                //        select ciw;
                //List<CourseInWork> lci = new List<CourseInWork>();
                //foreach (CourseInWork ciw in q)
                //{
                //    if (ciw.Fact == (short)WorkloadType.Фактическая && ciw.Employee.PostID != 5)
                //    {
                //        CourseInWork ciwTwin = ciw.GetTwin(q);
                //        if (ciwTwin == null)
                //            throw new Exception("У курса " + ciw.FullName + " не может отсутствовать двойник.");
                //        if (ciwTwin.Employee.PostID == 5)
                //            twinCourses.Add(ciw);
                //    }
                //}
            }
        }