using LYFZ.ComponentLibrary; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.UI.DecisionAssistant { public partial class AnalyzedEmployeePerformanceFormMain : LYFZ.ComponentLibrary.BaseContentsFormMain { public AnalyzedEmployeePerformanceFormMain() { InitializeComponent(); this.UcNavigationTool.LabTitle = "员工业绩分析"; this.panelEx1.BackColor = UIBlueThemeResources.AreaBackgroundColor; this.panelEx1.BorderColor = UIBlueThemeResources.BorderAreaColor; this.panelEx1.BorderStyle = BorderStyle.FixedSingle; this.labelEx1.BackColor = UIBlueThemeResources.TitleBackgroundColor; this.labelEx2.BackColor = UIBlueThemeResources.TitleBackgroundColor; int yearCount = DateTime.Now.Year; for(int i = yearCount-10 ; i<= yearCount ; i++) { cbo_CheckYear.Items.Add(i + "年"); cbo_Year.Items.Add(i + "年"); } cbo_CheckYear.SelectedItem = DateTime.Now.Year + "年"; cbo_Year.SelectedItem = DateTime.Now.Year + "年"; cbo_Mouth.SelectedItem = DateTime.Now.Month + "月"; cbo_CheckMouth.SelectedItem = DateTime.Now.Month + "月"; rdo_Day.Click += rdo_Day_Click; rdo_Mouth.Click += rdo_Day_Click; rdo_Stage.Click += rdo_Day_Click; rdo_Year.Click += rdo_Day_Click; cbo_Year.SelectedIndexChanged += cbo_Year_SelectedIndexChanged; cbo_Mouth.SelectedIndexChanged += cbo_Year_SelectedIndexChanged; cbo_CheckYear.SelectedIndexChanged += cbo_Year_SelectedIndexChanged; cbo_CheckMouth.SelectedIndexChanged += cbo_Year_SelectedIndexChanged; } void cbo_Year_SelectedIndexChanged(object sender, EventArgs e) { string controlName = (sender as Control).Name; switch(controlName) { case "cbo_Year": if(rdo_Mouth.Checked||rdo_Year.Checked) { dtDataTimeStart.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), dtDataTimeStart.Value.Month, dtDataTimeStart.Value.Day); dtDataTimeEnd.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), dtDataTimeEnd.Value.Month, dtDataTimeEnd.Value.Day); } break; case "cbo_Mouth": if (rdo_Mouth.Checked ) { dtDataTimeStart.Value = new DateTime(dtDataTimeStart.Value.Year, Convert.ToInt32(cbo_Mouth.Text.Replace("月", "")), dtDataTimeStart.Value.Day); if (rdo_Mouth.Checked) { dtDataTimeEnd.Value = new DateTime(dtDataTimeEnd.Value.Year, Convert.ToInt32(cbo_Mouth.Text.Replace("月", "")), 1); dtDataTimeEnd.Value = dtDataTimeEnd.Value.AddMonths(1).AddDays(-1); } else if (rdo_Day.Checked) { dtDataTimeEnd.Value = new DateTime(dtDataTimeStart.Value.Year, dtDataTimeStart.Value.Month, dtDataTimeStart.Value.Day); } } break; case "cbo_CheckYear": if (rdo_Mouth.Checked || rdo_Year.Checked) { dtDataTimeStartCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), dtDataTimeStartCompared.Value.Month, dtDataTimeStartCompared.Value.Day); dtDateTimeEndCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), dtDateTimeEndCompared.Value.Month, dtDateTimeEndCompared.Value.Day); } break; case "cbo_CheckMouth": if (rdo_Mouth.Checked) { dtDataTimeStartCompared.Value = new DateTime(dtDataTimeStartCompared.Value.Year, Convert.ToInt32(cbo_CheckMouth.Text.Replace("月", "")), dtDataTimeStartCompared.Value.Day); if (rdo_Mouth.Checked) { dtDateTimeEndCompared.Value = new DateTime(dtDateTimeEndCompared.Value.Year, Convert.ToInt32(cbo_CheckMouth.Text.Replace("月", "")), 1); dtDateTimeEndCompared.Value = dtDateTimeEndCompared.Value.AddMonths(1).AddDays(-1); } else if (rdo_Day.Checked) { dtDateTimeEndCompared.Value = new DateTime(dtDataTimeStartCompared.Value.Year, dtDataTimeStartCompared.Value.Month, dtDataTimeStartCompared.Value.Day); } } break; } } public void rdo_Day_Click(object sender, EventArgs e) { if(rdo_Day.Checked) { ShowAndHideControl("day"); dtDataTimeEnd.Value = new DateTime(dtDataTimeStart.Value.Year, dtDataTimeStart.Value.Month, dtDataTimeStart.Value.Day); if (chkComparedStartUp.Checked) { dtDateTimeEndCompared.Value = new DateTime(dtDataTimeStartCompared.Value.Year, dtDataTimeStartCompared.Value.Month, dtDataTimeStartCompared.Value.Day); } } else if (rdo_Mouth.Checked) { ShowAndHideControl("mouth"); dtDataTimeStart.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), Convert.ToInt32(cbo_Mouth.Text.Replace("月", "")), 1); dtDataTimeEnd.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), Convert.ToInt32(cbo_Mouth.Text.Replace("月", "")), 1); dtDataTimeEnd.Value = dtDataTimeEnd.Value.AddMonths(1).AddDays(-1); if (chkComparedStartUp.Checked) { dtDataTimeStartCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), Convert.ToInt32(cbo_CheckMouth.Text.Replace("月", "")), 1); dtDateTimeEndCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), Convert.ToInt32(cbo_CheckMouth.Text.Replace("月", "")), 1); dtDateTimeEndCompared.Value = dtDateTimeEndCompared.Value.AddMonths(1).AddDays(-1); } } else if (rdo_Year.Checked) { ShowAndHideControl("year"); dtDataTimeStart.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), 1, 1); dtDataTimeEnd.Value = new DateTime(Convert.ToInt32(cbo_Year.Text.Replace("年", "")), 12, 31); if (chkComparedStartUp.Checked) { dtDataTimeStartCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), 1, 1); dtDateTimeEndCompared.Value = new DateTime(Convert.ToInt32(cbo_CheckYear.Text.Replace("年", "")), 12, 31); } } else if (rdo_Stage.Checked) { ShowAndHideControl("stage"); } } void ShowAndHideControl(string type) { dtDataTimeStart.Visible = false; dtDataTimeEnd.Visible = false; cbo_Year.Visible = false; cbo_Mouth.Visible = false; if (chkComparedStartUp.Checked) { labelEx3.Visible = false; dtDataTimeStartCompared.Visible = false; dtDateTimeEndCompared.Visible = false; cbo_CheckYear.Visible = false; cbo_CheckMouth.Visible = false; } labelEx4.Visible = false; switch(type) { case "day": dtDataTimeStart.Visible = true; if (chkComparedStartUp.Checked) { dtDataTimeStartCompared.Visible = true; } break; case "mouth": cbo_Year.Visible = true; cbo_Mouth.Visible = true; if (chkComparedStartUp.Checked) { cbo_CheckYear.Visible = true; cbo_CheckMouth.Visible = true; } break; case "year": cbo_Year.Visible = true; if (chkComparedStartUp.Checked) { cbo_CheckYear.Visible = true; } break; case "stage": labelEx4.Visible = true; dtDataTimeStart.Visible = true; dtDataTimeEnd.Visible = true; if (chkComparedStartUp.Checked) { labelEx3.Visible = true; dtDataTimeStartCompared.Visible = true; dtDateTimeEndCompared.Visible = true; } break; } } } }