private void SetDefaultValuesForNowStatistic(ref ShiftStatisticClass a) { a.ScrapAmount = 0; a.AdditionalJobs = 0; a.A_Rolls_amount = 0; a.A_Rolls_amount = 0; a.PeopleAmount = 0; a.Prodused = 0; a.ShiftName = "-1"; }
private void ShiftStatistic_Load(object sender, EventArgs e) { textBox1.Text = ref_NowStatistic.ScrapAmount.ToString(); textBox2.Text = ref_NowStatistic.AdditionalJobs.ToString(); textBox3.Text = ref_NowStatistic.A_Rolls_amount.ToString(); textBox4.Text = ref_NowStatistic.C_Rolls_amount.ToString(); textBox5.Text = ref_NowStatistic.PeopleAmount.ToString(); ShiftStatisticClass Shiftstatistic_1 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_2 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_3 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_4 = new ShiftStatisticClass(); Shiftstatistic_1.GetLastShiftData("1"); Shiftstatistic_2.GetLastShiftData("2"); Shiftstatistic_3.GetLastShiftData("3"); Shiftstatistic_4.GetLastShiftData("4"); label28.Text = Shiftstatistic_1.Prodused.ToString(); label30.Text = Shiftstatistic_1.Efficiency.ToString(); label32.Text = Shiftstatistic_1.ScrapAmount.ToString(); label34.Text = Shiftstatistic_1.A_Rolls_amount.ToString(); label36.Text = Shiftstatistic_1.C_Rolls_amount.ToString(); label38.Text = Shiftstatistic_1.PeopleAmount.ToString(); label40.Text = Shiftstatistic_2.Prodused.ToString(); label42.Text = Shiftstatistic_2.Efficiency.ToString(); label44.Text = Shiftstatistic_2.ScrapAmount.ToString(); label46.Text = Shiftstatistic_2.A_Rolls_amount.ToString(); label48.Text = Shiftstatistic_2.C_Rolls_amount.ToString(); label50.Text = Shiftstatistic_2.PeopleAmount.ToString(); label52.Text = Shiftstatistic_3.Prodused.ToString(); label54.Text = Shiftstatistic_3.Efficiency.ToString(); label56.Text = Shiftstatistic_3.ScrapAmount.ToString(); label58.Text = Shiftstatistic_3.A_Rolls_amount.ToString(); label60.Text = Shiftstatistic_3.C_Rolls_amount.ToString(); label62.Text = Shiftstatistic_3.PeopleAmount.ToString(); label64.Text = Shiftstatistic_4.Prodused.ToString(); label66.Text = Shiftstatistic_4.Efficiency.ToString(); label68.Text = Shiftstatistic_4.ScrapAmount.ToString(); label70.Text = Shiftstatistic_4.A_Rolls_amount.ToString(); label72.Text = Shiftstatistic_4.C_Rolls_amount.ToString(); label74.Text = Shiftstatistic_4.PeopleAmount.ToString(); ShiftStatisticClass ShiftstatisticPerMonth_1 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_2 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_3 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_4 = new ShiftStatisticClass(); ShiftstatisticPerMonth_1.GetLastShiftDataPerMonth("1"); ShiftstatisticPerMonth_2.GetLastShiftDataPerMonth("2"); ShiftstatisticPerMonth_3.GetLastShiftDataPerMonth("3"); ShiftstatisticPerMonth_4.GetLastShiftDataPerMonth("4"); label29.Text = ShiftstatisticPerMonth_1.Prodused.ToString(); label31.Text = ShiftstatisticPerMonth_1.Efficiency.ToString(); label33.Text = ShiftstatisticPerMonth_1.ScrapAmount.ToString(); label35.Text = ShiftstatisticPerMonth_1.A_Rolls_amount.ToString(); label37.Text = ShiftstatisticPerMonth_1.C_Rolls_amount.ToString(); label39.Text = ShiftstatisticPerMonth_1.PeopleAmount.ToString(); //MessageBox.Show() label41.Text = ShiftstatisticPerMonth_2.Prodused.ToString(); label43.Text = ShiftstatisticPerMonth_2.Efficiency.ToString(); label45.Text = ShiftstatisticPerMonth_2.ScrapAmount.ToString(); label47.Text = ShiftstatisticPerMonth_2.A_Rolls_amount.ToString(); label49.Text = ShiftstatisticPerMonth_2.C_Rolls_amount.ToString(); label51.Text = ShiftstatisticPerMonth_2.PeopleAmount.ToString(); label53.Text = ShiftstatisticPerMonth_3.Prodused.ToString(); label55.Text = ShiftstatisticPerMonth_3.Efficiency.ToString(); label57.Text = ShiftstatisticPerMonth_3.ScrapAmount.ToString(); label59.Text = ShiftstatisticPerMonth_3.A_Rolls_amount.ToString(); label61.Text = ShiftstatisticPerMonth_3.C_Rolls_amount.ToString(); label63.Text = ShiftstatisticPerMonth_3.PeopleAmount.ToString(); label65.Text = ShiftstatisticPerMonth_4.Prodused.ToString(); label67.Text = ShiftstatisticPerMonth_4.Efficiency.ToString(); label69.Text = ShiftstatisticPerMonth_4.ScrapAmount.ToString(); label71.Text = ShiftstatisticPerMonth_4.A_Rolls_amount.ToString(); label73.Text = ShiftstatisticPerMonth_4.C_Rolls_amount.ToString(); label75.Text = ShiftstatisticPerMonth_4.PeopleAmount.ToString(); }
public ShiftStatistic(ShiftStatisticClass a) { ref_NowStatistic = a; InitializeComponent(); }
private void SetDefaultValuesForNowStatistic(ref ShiftStatisticClass a) { a.ScrapAmount = 0; a.AdditionalJobs = 0; a.A_Rolls_amount = 0; a.A_Rolls_amount = 0; a.PeopleAmount = 0; a.Prodused = 0; a.ShiftName = "-1"; }
public int GetScoreShiftPerMonth(String in_shift_name) { ShiftStatisticClass ShiftData_list_entry = new ShiftStatisticClass(); List <ShiftStatisticClass> ShiftData_list = new List <ShiftStatisticClass>(); try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); } } } catch { } int average_score = 0; int ShiftFrequency = 0; foreach (ShiftStatisticClass a in ShiftData_list) { if (a.ShiftName == in_shift_name && (a.ShiftStartDateTime.Month == DateTime.Now.Month && a.ShiftStartDateTime.Year == DateTime.Now.Year)) { average_score += a.GetTotalScore(); ShiftFrequency++; //MessageBox.Show(ShiftFrequency.ToString()); } } average_score /= ShiftFrequency; //MessageBox.Show(ShiftFrequency.ToString()); return(average_score); }
public void GetLastShiftData(String in_shift_name) { List <ShiftStatisticClass> ShiftData_list = new List <ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry; //fill ShiftData_list try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); //MessageBox.Show(ShiftData_list[ShiftData_list.Count - 1].ShiftName.ToString() + " " + ShiftData_list[0].ShiftName.ToString()); } } } catch { } //get requaried shift with earliest data DateTime temp_datetime = DateTime.MinValue; foreach (ShiftStatisticClass a in ShiftData_list) { //MessageBox.Show(a.ShiftName.ToString()); if (a.ShiftName == in_shift_name && a.ShiftStartDateTime > Convert.ToDateTime(temp_datetime)) { temp_datetime = a.ShiftStartDateTime; this.ShiftName = a.ShiftName; this.Prodused = a.Prodused; this.Efficiency = a.Efficiency; this.ScrapAmount = a.ScrapAmount; this.AdditionalJobs = a.AdditionalJobs; this.A_Rolls_amount = a.A_Rolls_amount; this.C_Rolls_amount = a.C_Rolls_amount; this.PeopleAmount = a.PeopleAmount; } } }
public void GetLastShiftDataPerMonth(String in_shift_name) { List <ShiftStatisticClass> ShiftData_list = new List <ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry; //fill ShiftData_list try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); //MessageBox.Show(ShiftData_list[ShiftData_list.Count - 1].ShiftName.ToString() + " " + ShiftData_list[0].ShiftName.ToString()); } } } catch { } //get required shift with earliest data int ShiftFrequency = 0; foreach (ShiftStatisticClass a in ShiftData_list) { //MessageBox.Show(a.ShiftName.ToString()); if (a.ShiftName == in_shift_name && (a.ShiftStartDateTime.Month == DateTime.Now.Month && a.ShiftStartDateTime.Year == DateTime.Now.Year)) { this.ShiftName += a.ShiftName; this.Prodused += a.Prodused; this.Efficiency += a.Efficiency; this.ScrapAmount += a.ScrapAmount; this.AdditionalJobs += a.AdditionalJobs; this.A_Rolls_amount += a.A_Rolls_amount; this.C_Rolls_amount += a.C_Rolls_amount; this.PeopleAmount += a.PeopleAmount; ShiftFrequency++; } } //MessageBox.Show( // "this.ShiftName " + this.ShiftName + // "\nthis.Prodused " + this.Prodused + // "\nthis.Efficiency " + this.Efficiency + // "\nthis.ScrapAmount " + this.ScrapAmount + // "\nthis.AdditionalJobs " + this.AdditionalJobs + // "\nthis.A_Rolls_amount " + this.A_Rolls_amount + // "\nthis.C_Rolls_amount " + this.C_Rolls_amount + // "\nthis.PeopleAmount " + this.PeopleAmount // ); if (ShiftFrequency != 0) { //MessageBox.Show(ShiftFrequency.ToString()); //this.Prodused /= ShiftFrequency; this.Efficiency /= ShiftFrequency; //this.ScrapAmount /= ShiftFrequency; //this.AdditionalJobs /= ShiftFrequency; //this.A_Rolls_amount /= ShiftFrequency; //this.C_Rolls_amount /= ShiftFrequency; this.PeopleAmount /= ShiftFrequency; } if (ShiftFrequency == 0) { this.Prodused = 0; this.Efficiency = 0; this.ScrapAmount = 0; this.AdditionalJobs = 0; this.A_Rolls_amount = 0; this.C_Rolls_amount = 0; this.PeopleAmount = 0; } }
private void PushStatisticData(ShiftStatisticClass a) { //2190 records - 3 years List <ShiftStatisticClass> ShiftData_list = new List <ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry = new ShiftStatisticClass(); try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { // entire_str = sr.ReadLine(); part_str = ""; for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] == ';') { i++; local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = /*0*/ Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = /*0*/ Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } else { part_str += entire_str[i]; } } ShiftData_list.Add(ShiftData_list_entry); } } } catch { } try { using (StreamWriter sw = new StreamWriter(@"ShiftStatisticData.txt", true)) { for (int i = 0; i < ShiftData_list.Count; i++) { sw.WriteLine(ShiftData_list[i].ShiftStartDateTime + ";" + ShiftData_list[i].ShiftName + ";" + ShiftData_list[i].Prodused + ";" + ShiftData_list[i].Efficiency + ";" + ShiftData_list[i].ScrapAmount.ToString() + ";" + ShiftData_list[i].AdditionalJobs.ToString() + ";" + ShiftData_list[i].A_Rolls_amount.ToString() + ";" + ShiftData_list[i].C_Rolls_amount.ToString() + ";" + ShiftData_list[i].PeopleAmount.ToString() + ";" ); } #region Only For Calander //get summary balasted time for calander TimeSpan SummaryExeeded0Statustime = new TimeSpan(0, 0, 0); for (int i = 0; i < DGGlobalObject.Count; i++) { if (DGGlobalObject[i].MachineState == "0") { SummaryExeeded0Statustime = TimeSpan.FromSeconds(Convert.ToDouble(DGGlobalObject[i].SummaryTime)) - cal_green_time; } } #endregion sw.WriteLine(get_CURR().ToString() + ";" + a.ShiftName.ToString() + ";" + metersPerShift.ToString() + ";"/*"0;"*/ + Math.Round( (1 - ((sql_obj.GetBalastedTimes(get_T1(dateTimePicker1.Value), get_T2(dateTimePicker1.Value), get_CURR()) + SummaryExeeded0Statustime).TotalSeconds / (get_CURR() - get_T1(dateTimePicker1.Value)).TotalSeconds ) ) * 100, 1 ).ToString() + ";" + a.ScrapAmount.ToString() + ";" + a.AdditionalJobs.ToString() + ";" + a.A_Rolls_amount.ToString() + ";" + a.C_Rolls_amount.ToString() + ";" + a.PeopleAmount.ToString() + ";" ); } } catch { } }
public void DrawTotalScore() { #region Draw Total Score ShiftStatisticClass temp = new ShiftStatisticClass(); int total_score_shift1 = 0, total_score_shift2 = 0, total_score_shift3 = 0, total_score_shift4 = 0; temp = new ShiftStatisticClass(); try { total_score_shift1 = temp.GetScoreShiftPerMonth("1"); label16.Text = total_score_shift1.ToString(); } catch { label16.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift2 = temp.GetScoreShiftPerMonth("2"); label17.Text = total_score_shift2.ToString(); } catch { label17.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift3 = temp.GetScoreShiftPerMonth("3"); label18.Text = total_score_shift3.ToString(); } catch { label18.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift4 = temp.GetScoreShiftPerMonth("4"); label19.Text = total_score_shift4.ToString(); } catch { label19.Text = "0"; } int max_total_score = 0; max_total_score = (total_score_shift1 > max_total_score) ? total_score_shift1 : max_total_score; max_total_score = (total_score_shift2 > max_total_score) ? total_score_shift2 : max_total_score; max_total_score = (total_score_shift3 > max_total_score) ? total_score_shift3 : max_total_score; max_total_score = (total_score_shift4 > max_total_score) ? total_score_shift4 : max_total_score; int red_factor = 0; int green_factor = 0; int add = 0; add = (max_total_score != 0) ? (int)(((double)total_score_shift1 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel1.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel1.Width = (int)(((double)total_score_shift1 / (double)max_total_score) * 100); if (panel1.Width == 0) { panel1.Width = 3; } add = (max_total_score != 0) ? (int)(((double)total_score_shift2 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel2.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel2.Width = (int)(((double)total_score_shift2 / (double)max_total_score) * 100); if (panel2.Width == 0) { panel2.Width = 3; } add = (max_total_score != 0) ? (int)(((double)total_score_shift3 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel3.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel3.Width = (int)(((double)total_score_shift3 / (double)max_total_score) * 100); if (panel3.Width == 0) { panel3.Width = 3; } add = (max_total_score != 0) ? (int)(((double)total_score_shift4 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel4.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel4.Width = (int)(((double)total_score_shift4 / (double)max_total_score) * 100); if (panel4.Width == 0) { panel4.Width = 3; } #endregion }
public int GetScoreShiftPerMonth(String in_shift_name) { ShiftStatisticClass ShiftData_list_entry = new ShiftStatisticClass(); List<ShiftStatisticClass> ShiftData_list = new List<ShiftStatisticClass>(); try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); } } } catch { } int average_score=0; int ShiftFrequency = 0; foreach (ShiftStatisticClass a in ShiftData_list) { if (a.ShiftName == in_shift_name && (a.ShiftStartDateTime.Month == DateTime.Now.Month && a.ShiftStartDateTime.Year == DateTime.Now.Year)) { average_score +=a.GetTotalScore(); ShiftFrequency++; //MessageBox.Show(ShiftFrequency.ToString()); } } average_score /= ShiftFrequency; //MessageBox.Show(ShiftFrequency.ToString()); return average_score; }
public void GetLastShiftData(String in_shift_name) { List<ShiftStatisticClass> ShiftData_list = new List<ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry; //fill ShiftData_list try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); //MessageBox.Show(ShiftData_list[ShiftData_list.Count - 1].ShiftName.ToString() + " " + ShiftData_list[0].ShiftName.ToString()); } } } catch { } //get requaried shift with earliest data DateTime temp_datetime = DateTime.MinValue; foreach (ShiftStatisticClass a in ShiftData_list) { //MessageBox.Show(a.ShiftName.ToString()); if (a.ShiftName == in_shift_name && a.ShiftStartDateTime > Convert.ToDateTime(temp_datetime)) { temp_datetime = a.ShiftStartDateTime; this.ShiftName = a.ShiftName; this.Prodused = a.Prodused; this.Efficiency = a.Efficiency; this.ScrapAmount = a.ScrapAmount; this.AdditionalJobs = a.AdditionalJobs; this.A_Rolls_amount = a.A_Rolls_amount; this.C_Rolls_amount = a.C_Rolls_amount; this.PeopleAmount = a.PeopleAmount; } } }
public void GetLastShiftDataPerMonth(String in_shift_name) { List<ShiftStatisticClass> ShiftData_list = new List<ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry; //fill ShiftData_list try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { //MessageBox.Show(in_shift_name); String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { entire_str = sr.ReadLine(); //sr. //MessageBox.Show(entire_str); part_str = ""; local_cnt = 0; ShiftData_list_entry = new ShiftStatisticClass(); for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] != ';') { part_str += entire_str[i]; } if (entire_str[i] == ';') { local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } } ShiftData_list.Add(ShiftData_list_entry); //MessageBox.Show(ShiftData_list[ShiftData_list.Count - 1].ShiftName.ToString() + " " + ShiftData_list[0].ShiftName.ToString()); } } } catch { } //get required shift with earliest data int ShiftFrequency = 0; foreach (ShiftStatisticClass a in ShiftData_list) { //MessageBox.Show(a.ShiftName.ToString()); if (a.ShiftName == in_shift_name && (a.ShiftStartDateTime.Month == DateTime.Now.Month && a.ShiftStartDateTime.Year == DateTime.Now.Year)) { this.ShiftName += a.ShiftName; this.Prodused += a.Prodused; this.Efficiency += a.Efficiency; this.ScrapAmount += a.ScrapAmount; this.AdditionalJobs += a.AdditionalJobs; this.A_Rolls_amount += a.A_Rolls_amount; this.C_Rolls_amount += a.C_Rolls_amount; this.PeopleAmount += a.PeopleAmount; ShiftFrequency++; } } //MessageBox.Show( // "this.ShiftName " + this.ShiftName + // "\nthis.Prodused " + this.Prodused + // "\nthis.Efficiency " + this.Efficiency + // "\nthis.ScrapAmount " + this.ScrapAmount + // "\nthis.AdditionalJobs " + this.AdditionalJobs + // "\nthis.A_Rolls_amount " + this.A_Rolls_amount + // "\nthis.C_Rolls_amount " + this.C_Rolls_amount + // "\nthis.PeopleAmount " + this.PeopleAmount // ); if (ShiftFrequency != 0) { //MessageBox.Show(ShiftFrequency.ToString()); //this.Prodused /= ShiftFrequency; this.Efficiency /= ShiftFrequency; //this.ScrapAmount /= ShiftFrequency; //this.AdditionalJobs /= ShiftFrequency; //this.A_Rolls_amount /= ShiftFrequency; //this.C_Rolls_amount /= ShiftFrequency; this.PeopleAmount /= ShiftFrequency; } if (ShiftFrequency == 0) { this.Prodused = 0; this.Efficiency = 0; this.ScrapAmount = 0; this.AdditionalJobs = 0; this.A_Rolls_amount = 0; this.C_Rolls_amount = 0; this.PeopleAmount = 0; } }
public void DrawTotalScore() { #region Draw Total Score ShiftStatisticClass temp = new ShiftStatisticClass(); int total_score_shift1 = 0, total_score_shift2 = 0, total_score_shift3 = 0, total_score_shift4 = 0; temp = new ShiftStatisticClass(); try { total_score_shift1 = temp.GetScoreShiftPerMonth("1"); label16.Text = total_score_shift1.ToString(); } catch { label16.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift2 = temp.GetScoreShiftPerMonth("2"); label17.Text = total_score_shift2.ToString(); } catch { label17.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift3 = temp.GetScoreShiftPerMonth("3"); label18.Text = total_score_shift3.ToString(); } catch { label18.Text = "0"; } temp = new ShiftStatisticClass(); try { total_score_shift4 = temp.GetScoreShiftPerMonth("4"); label19.Text = total_score_shift4.ToString(); } catch { label19.Text = "0"; } int max_total_score = 0; max_total_score = (total_score_shift1 > max_total_score) ? total_score_shift1 : max_total_score; max_total_score = (total_score_shift2 > max_total_score) ? total_score_shift2 : max_total_score; max_total_score = (total_score_shift3 > max_total_score) ? total_score_shift3 : max_total_score; max_total_score = (total_score_shift4 > max_total_score) ? total_score_shift4 : max_total_score; int red_factor = 0; int green_factor = 0; int add = 0; add = (max_total_score != 0) ? (int)(((double)total_score_shift1 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add>=0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add<=511) { red_factor = 255 - (add - 256); green_factor = 255; } panel1.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel1.Width = (int)(((double)total_score_shift1 / (double)max_total_score) * 100); if (panel1.Width == 0) panel1.Width = 3; add = (max_total_score != 0) ? (int)(((double)total_score_shift2 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel2.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel2.Width = (int)(((double)total_score_shift2 / (double)max_total_score) * 100); if (panel2.Width == 0) panel2.Width = 3; add = (max_total_score != 0) ? (int)(((double)total_score_shift3 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel3.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel3.Width = (int)(((double)total_score_shift3 / (double)max_total_score) * 100); if (panel3.Width == 0) panel3.Width = 3; add = (max_total_score != 0) ? (int)(((double)total_score_shift4 / (double)max_total_score) * 511) : 0; red_factor = 0; green_factor = 0; if (add >= 0 && add <= 255) { red_factor = 255; green_factor = add; } if (add > 255 && add <= 511) { red_factor = 255 - (add - 256); green_factor = 255; } panel4.BackColor = Color.FromArgb(red_factor, green_factor, 0); panel4.Width = (int)(((double)total_score_shift4 / (double)max_total_score) * 100); if (panel4.Width == 0) panel4.Width = 3; #endregion }
private void PushStatisticData(ShiftStatisticClass a) { //2190 records - 3 years List<ShiftStatisticClass> ShiftData_list = new List<ShiftStatisticClass>(); ShiftStatisticClass ShiftData_list_entry = new ShiftStatisticClass(); try { using (StreamReader sr = new StreamReader(@"ShiftStatisticData.txt")) { String entire_str, part_str; int local_cnt = 0; //pointer of data in string while (!sr.EndOfStream) { // entire_str = sr.ReadLine(); part_str = ""; for (int i = 0; i < entire_str.Length; i++) { if (entire_str[i] == ';') { i++; local_cnt++; if (local_cnt == 1) { ShiftData_list_entry.ShiftStartDateTime = Convert.ToDateTime(part_str); } if (local_cnt == 2) { ShiftData_list_entry.ShiftName = part_str; } if (local_cnt == 3) { ShiftData_list_entry.Prodused = /*0*/ Convert.ToDouble(part_str); } if (local_cnt == 4) { ShiftData_list_entry.Efficiency = /*0*/ Convert.ToDouble(part_str); } if (local_cnt == 5) { ShiftData_list_entry.ScrapAmount = Convert.ToDouble(part_str); } if (local_cnt == 6) { ShiftData_list_entry.AdditionalJobs = Convert.ToDouble(part_str); } if (local_cnt == 7) { ShiftData_list_entry.A_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 8) { ShiftData_list_entry.C_Rolls_amount = Convert.ToDouble(part_str); } if (local_cnt == 9) { ShiftData_list_entry.PeopleAmount = Convert.ToInt32(part_str); } part_str = ""; } else { part_str += entire_str[i]; } } ShiftData_list.Add(ShiftData_list_entry); } } } catch { } try { using (StreamWriter sw = new StreamWriter(@"ShiftStatisticData.txt", true)) { for (int i=0;i<ShiftData_list.Count;i++) { sw.WriteLine(ShiftData_list[i].ShiftStartDateTime + ";" + ShiftData_list[i].ShiftName + ";" + ShiftData_list[i].Prodused + ";" + ShiftData_list[i].Efficiency + ";" + ShiftData_list[i].ScrapAmount.ToString() + ";" + ShiftData_list[i].AdditionalJobs.ToString() + ";" + ShiftData_list[i].A_Rolls_amount.ToString() + ";" + ShiftData_list[i].C_Rolls_amount.ToString() + ";" + ShiftData_list[i].PeopleAmount.ToString() + ";" ); } #region Only For Calander //get summary balasted time for calander TimeSpan SummaryExeeded0Statustime = new TimeSpan(0, 0, 0); for (int i = 0; i < DGGlobalObject.Count; i++) { if (DGGlobalObject[i].MachineState == "0") { SummaryExeeded0Statustime = TimeSpan.FromSeconds(Convert.ToDouble(DGGlobalObject[i].SummaryTime)) - cal_green_time; } } #endregion sw.WriteLine(get_CURR().ToString() + ";" + a.ShiftName.ToString() + ";" + metersPerShift.ToString() + ";"/*"0;"*/ + Math.Round( (1 - ((sql_obj.GetBalastedTimes(get_T1(dateTimePicker1.Value), get_T2(dateTimePicker1.Value), get_CURR()) + SummaryExeeded0Statustime).TotalSeconds / (get_CURR() - get_T1(dateTimePicker1.Value)).TotalSeconds ) ) * 100, 1 ).ToString() + ";" + a.ScrapAmount.ToString() + ";" + a.AdditionalJobs.ToString() + ";" + a.A_Rolls_amount.ToString() + ";" + a.C_Rolls_amount.ToString() + ";" + a.PeopleAmount.ToString() + ";" ); } } catch { } }
private void ShiftStatistic_Load(object sender, EventArgs e) { textBox1.Text = ref_NowStatistic.ScrapAmount.ToString(); textBox2.Text = ref_NowStatistic.AdditionalJobs.ToString(); textBox3.Text = ref_NowStatistic.A_Rolls_amount.ToString(); textBox4.Text = ref_NowStatistic.C_Rolls_amount.ToString(); textBox5.Text = ref_NowStatistic.PeopleAmount.ToString(); ShiftStatisticClass Shiftstatistic_1 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_2 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_3 = new ShiftStatisticClass(); ShiftStatisticClass Shiftstatistic_4 = new ShiftStatisticClass(); Shiftstatistic_1.GetLastShiftData("1"); Shiftstatistic_2.GetLastShiftData("2"); Shiftstatistic_3.GetLastShiftData("3"); Shiftstatistic_4.GetLastShiftData("4"); label28.Text = Shiftstatistic_1.Prodused.ToString(); label30.Text = Shiftstatistic_1.Efficiency.ToString(); label32.Text = Shiftstatistic_1.ScrapAmount.ToString(); label34.Text = Shiftstatistic_1.A_Rolls_amount.ToString(); label36.Text = Shiftstatistic_1.C_Rolls_amount.ToString(); label38.Text = Shiftstatistic_1.PeopleAmount.ToString(); label40.Text = Shiftstatistic_2.Prodused.ToString(); label42.Text = Shiftstatistic_2.Efficiency.ToString(); label44.Text = Shiftstatistic_2.ScrapAmount.ToString(); label46.Text = Shiftstatistic_2.A_Rolls_amount.ToString(); label48.Text = Shiftstatistic_2.C_Rolls_amount.ToString(); label50.Text = Shiftstatistic_2.PeopleAmount.ToString(); label52.Text = Shiftstatistic_3.Prodused.ToString(); label54.Text = Shiftstatistic_3.Efficiency.ToString(); label56.Text = Shiftstatistic_3.ScrapAmount.ToString(); label58.Text = Shiftstatistic_3.A_Rolls_amount.ToString(); label60.Text = Shiftstatistic_3.C_Rolls_amount.ToString(); label62.Text = Shiftstatistic_3.PeopleAmount.ToString(); label64.Text = Shiftstatistic_4.Prodused.ToString(); label66.Text = Shiftstatistic_4.Efficiency.ToString(); label68.Text = Shiftstatistic_4.ScrapAmount.ToString(); label70.Text = Shiftstatistic_4.A_Rolls_amount.ToString(); label72.Text = Shiftstatistic_4.C_Rolls_amount.ToString(); label74.Text = Shiftstatistic_4.PeopleAmount.ToString(); ShiftStatisticClass ShiftstatisticPerMonth_1 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_2 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_3 = new ShiftStatisticClass(); ShiftStatisticClass ShiftstatisticPerMonth_4 = new ShiftStatisticClass(); ShiftstatisticPerMonth_1.GetLastShiftDataPerMonth("1"); ShiftstatisticPerMonth_2.GetLastShiftDataPerMonth("2"); ShiftstatisticPerMonth_3.GetLastShiftDataPerMonth("3"); ShiftstatisticPerMonth_4.GetLastShiftDataPerMonth("4"); label29.Text = ShiftstatisticPerMonth_1.Prodused.ToString(); label31.Text = ShiftstatisticPerMonth_1.Efficiency.ToString(); label33.Text = ShiftstatisticPerMonth_1.ScrapAmount.ToString(); label35.Text = ShiftstatisticPerMonth_1.A_Rolls_amount.ToString(); label37.Text = ShiftstatisticPerMonth_1.C_Rolls_amount.ToString(); label39.Text = ShiftstatisticPerMonth_1.PeopleAmount.ToString(); //MessageBox.Show() label41.Text = ShiftstatisticPerMonth_2.Prodused.ToString(); label43.Text = ShiftstatisticPerMonth_2.Efficiency.ToString(); label45.Text = ShiftstatisticPerMonth_2.ScrapAmount.ToString(); label47.Text = ShiftstatisticPerMonth_2.A_Rolls_amount.ToString(); label49.Text = ShiftstatisticPerMonth_2.C_Rolls_amount.ToString(); label51.Text = ShiftstatisticPerMonth_2.PeopleAmount.ToString(); label53.Text = ShiftstatisticPerMonth_3.Prodused.ToString(); label55.Text = ShiftstatisticPerMonth_3.Efficiency.ToString(); label57.Text = ShiftstatisticPerMonth_3.ScrapAmount.ToString(); label59.Text = ShiftstatisticPerMonth_3.A_Rolls_amount.ToString(); label61.Text = ShiftstatisticPerMonth_3.C_Rolls_amount.ToString(); label63.Text = ShiftstatisticPerMonth_3.PeopleAmount.ToString(); label65.Text = ShiftstatisticPerMonth_4.Prodused.ToString(); label67.Text = ShiftstatisticPerMonth_4.Efficiency.ToString(); label69.Text = ShiftstatisticPerMonth_4.ScrapAmount.ToString(); label71.Text = ShiftstatisticPerMonth_4.A_Rolls_amount.ToString(); label73.Text = ShiftstatisticPerMonth_4.C_Rolls_amount.ToString(); label75.Text = ShiftstatisticPerMonth_4.PeopleAmount.ToString(); }
public ShiftStatistic(ShiftStatisticClass a) { ref_NowStatistic = a; InitializeComponent(); }