private void load_employee_from_file(DateTime start_of_week) { string where = string.Format("BookDate >= '{0}' and BookDate <= '{1}'", start_of_week.ToShortDateString(), start_of_week.AddDays(14).ToShortDateString()); DataView v = new DataView(_dt_tb); v.RowFilter = where; DataTable view_data = v.ToTable(true, new string[] { "EmpId", "EmpName", "DefPayCode" }); // select distinct foreach (DataRow row in view_data.Rows) { if (_employee.ContainsKey(row["EmpID"].ToString())) { continue; } string paycode = "Hourly"; if (!row["DefPayCode"].Equals(DBNull.Value)) { paycode = (string)row["DefPayCode"]; } ucSalary uc = new ucSalary(start_of_week, row["EmpName"].ToString(), row["EmpID"].ToString(), paycode, true); _employee.Add(row["EmpID"].ToString(), uc); //tlpStaff.Controls.Add(uc); //tlpStaff.RowCount += 1; } }
private void chkHourly_CheckedChanged(object sender, EventArgs e) { CheckBox cb = (CheckBox)sender; foreach (var c in _employee) { ucSalary uc = c.Value; uc.DayUnit = cb.Checked;; uc.RedrawDays(); } }
/*******************************************************************************************************************\ * * \*******************************************************************************************************************/ private void reset_week(DateTime start_of_week) { foreach (var c in _employee) { ucSalary uc = c.Value; if (!uc.LoadIt) { uc.ShowIt = false; } uc.ResetWeek(start_of_week); } }
/*******************************************************************************************************************\ * * \*******************************************************************************************************************/ public void Show(string emp_id, DateTime refdate, string defpaycode) { this.Enabled = false; this.UseWaitCursor = true; if (_uc_paycode != null) { _uc_paycode.ShowCRUD(emp_id, refdate, defpaycode); } ucSalary uc = _employee[emp_id]; uc.QuickFresh(refdate, _uc_paycode.TotalRegHours, _uc_paycode.TotalOver, _uc_paycode.TotalOver1, _uc_paycode.TotalXtrHours); Application.DoEvents(); //backgroundWorker1.RunWorkerAsync(); _dt_tb = dacTimebook.GetDTCrew(DBO); //_uc_paycode.LoadDatatable(_dt_tb); this.Enabled = true; this.UseWaitCursor = false; }
private void do_save() { //DataSet ds = dacTimebook.GetDS(RefWeek, 14); for (int i = 0; i < tlpStaff.RowCount; i++) { ucSalary uc = (ucSalary)tlpStaff.GetControlFromPosition(0, i); if (!uc.EmpChk) { continue; } if (uc.IsDelete()) { continue; } if (!uc.IsDirty()) { continue; } MessageBox.Show(uc.EmpName, System.Reflection.MethodBase.GetCurrentMethod().ToString()); //RCD rcd = uc.RcdStat; //for (int j = 0; j <= 13; j++) // if (rcd.toff[j] != null) MessageBox.Show(rcd.toff[j].ToString()); DataRow row; DateTime next_date; for (int day = 0; day < 14; day++) { next_date = RefWeek.Date.AddDays(day); string toff = uc.EmpToff[day]; //string vessel = uc.EmpVessel[day]; string paycode = uc.DefPayCode; string empname = uc.EmpName; Decimal hour = uc.EmpHour[day]; Decimal over = uc.EmpOver[day]; Decimal over1 = uc.EmpOver1[day]; int shift = 0; string lognote = uc.EmpNote[day]; MessageBox.Show(string.Format("nd{0} e{1}", next_date, uc.EmpID), System.Reflection.MethodBase.GetCurrentMethod().ToString()); //dacTimebook.vwUpdTimebook(DBO, next_date, uc.EmpID, shift, toff, null, hour, over, over1, null, paycode); //row = ds.Tables[0].NewRow(); //row["EmpName"] = uc.EmpName; //if (toff != null && toff.Length == 0) // row["ToffCode"] = null; //else // row["ToffCode"] = toff; //row["LogHours"] = uc.EmpHour[day]; //row["LogOver"] = uc.EmpOver[day]; //if (vessel != null && vessel.Length == 0) // row["LogVessel"] = null; //else // row["LogVessel"] = uc.EmpVessel[day]; //row["LogShift"] = 0; //row["LogNote"] = null; //if (uc.EmpNote[day] != null && uc.EmpNote[day].Length > 0) // row["LogNote"] = uc.EmpNote[day]; //dacTimebook.FindAdd(new object[] { next_date, uc.EmpID, 0 }, row); //uc.SaveReset(); } } //dacTimebook.SaveData(); //dacCache.PutTimebook(); cmdSave.Visible = false; //DataSet ds = dacTimebook.GetDS(RefWeek, 14); //for (int i = 0; i < tlpCrew.RowCount; i++) //{ // ucSalary uc = (ucSalary)tlpCrew.GetControlFromPosition(0, i); // if (!uc.EmpChk) continue; // if (uc.IsDelete()) continue; // if (!uc.IsDirty()) continue; // //MessageBox.Show(uc.EmpName); // //RCD rcd = uc.RcdStat; // //for (int j = 0; j <= 13; j++) // // if (rcd.toff[j] != null) MessageBox.Show(rcd.toff[j].ToString()); // DataRow row; // DateTime next_date; // for (int day = 0; day < 14; day++) // { // next_date = RefWeek.Date.AddDays(day); // string toff = uc.EmpToff[day]; // string vessel = uc.EmpVessel[day]; // row = ds.Tables[0].NewRow(); // row["EmpName"] = uc.EmpName; // if (toff != null && toff.Length == 0) // row["ToffCode"] = null; // else // row["ToffCode"] = toff; // row["LogHours"] = uc.EmpHour[day]; // row["LogOver"] = uc.EmpOver[day]; // if (vessel != null && vessel.Length == 0) // row["LogVessel"] = null; // else // row["LogVessel"] = uc.EmpVessel[day]; // row["LogShift"] = 0; // row["LogNote"] = null; // if (uc.EmpNote[day] != null && uc.EmpNote[day].Length > 0) // row["LogNote"] = uc.EmpNote[day]; // dacTimebook.FindAdd(new object[] { next_date, uc.EmpID, 0 }, row); // uc.SaveReset(); // } //} //dacTimebook.SaveData(); ////dacCache.PutTimebook(); //cmdSave.Visible = false; }
private void refresh_data(DateTime start_of_week, bool show_all) { tlpStaff.Controls.Clear(); tlpStaff.RowCount = 0; //_ds_crew = dacTimebook.GetDS(RefWeek, 14); // _dt_crew is already loaded //load_shift(); string where = string.Format("BookDate >= '{0}' and BookDate <= '{1}'", start_of_week.ToShortDateString(), start_of_week.AddDays(14).ToShortDateString()); DataView v = new DataView(_dt_tb); //v.Table = _ds_crew.Tables[0]; //v.Table = _dt_crew; v.RowFilter = where; DataTable view_data = v.ToTable(true, new string[] { "EmpId", "EmpName", "DefPayCode" }); foreach (DataRow row in view_data.Rows) { ucSalary uc; if (_employee.ContainsKey(row["EmpID"].ToString())) { uc = _employee[row["EmpID"].ToString()]; if (show_all) { uc.ShowIt = true; } continue; } if (show_all) { string paycode = "Hourly"; if (!row["DefPayCode"].Equals(DBNull.Value)) { paycode = (string)row["DefPayCode"]; } uc = new ucSalary(start_of_week, row["EmpName"].ToString(), row["EmpID"].ToString(), paycode, false); _employee.Add(row["EmpID"].ToString(), uc); } //tlpCrew.Controls.Add(uc); //tlpCrew.RowCount += 1; } foreach (var c in _employee) { ucSalary uc = c.Value; if (uc.LoadIt) { tlpStaff.Controls.Add(uc); tlpStaff.RowCount += 1; } } foreach (var c in _employee) { ucSalary uc = c.Value; if (uc.ShowIt && !uc.LoadIt) { tlpStaff.Controls.Add(uc); tlpStaff.RowCount += 1; } } }
/*******************************************************************************************************************\ * * \*******************************************************************************************************************/ private void update_timebook(bool show_all) { if (RefWeek == null) { return; } //DataSet ds = dacTimebook.GetDS(RefWeek, 14); //foreach (DataRow row in ds.Tables[0].Rows) foreach (DataRow row in _dt_tb.Rows) { var bookdate_ = row["Bookdate"]; if (bookdate_ == DBNull.Value) { continue; } DateTime bookdate = (DateTime)bookdate_; //if (bookdate.Date < RefWeek.Date) continue; //if (bookdate.Date >= RefWeek.AddDays(14).Date) continue; if (bookdate.Date.CompareTo(RefWeek.Date) == -1) { continue; } if (bookdate.Date.CompareTo(RefWeek.AddDays(14).Date) == 1) { continue; } //ucStat uc = (ucStat)tlpCrew.GetControlFromPosition(0, 0); //if (!_crew.ContainsKey(row["EmpId"].ToString())) // load_crew_from_row(RefWeek, row); try { //if (row["EmpID"].Equals("FS0623")) MessageBox.Show("A"); if (!show_all && !_employee.ContainsKey(row["EmpID"].ToString())) { continue; } // GS180907 - Debug Stop //string eid = row["EmpID"].ToString(); //if (eid.Equals("K1")) MessageBox.Show("Here"); ucSalary uc = _employee[row["EmpID"].ToString()]; string notebug = null; // can't use row["LogNote"].ToString() if (!row["LogNote"].Equals(DBNull.Value)) { notebug = row["LogNote"].ToString(); } Decimal over1 = 0.0M; if (!row["LogOver1"].Equals(DBNull.Value)) { over1 = (Decimal)row["LogOver1"]; } // GS180907 - Handle Incomplete Employee Data if (row["DefPayCode"].Equals(DBNull.Value)) { string msg = string.Format("{0} : Employee : [{1}:{2}] {3}", "WARNING - This employee is not properly setup. The DefPayCode is not valid", row["EmpID"].ToString(), row["EmpName"].ToString(), bookdate ); MessageBox.Show(msg, System.Reflection.MethodBase.GetCurrentMethod().ToString()); continue; } string paycode = (string)row["DefPayCode"]; if (!row["PayCode"].Equals(DBNull.Value)) { paycode = (string)row["PayCode"]; } string toff = string.Empty; if (!row["ToffCode"].Equals(DBNull.Value)) { toff = (string)row["ToffCode"]; } string boat = string.Empty; if (!row["LogVessel"].Equals(DBNull.Value)) { boat = (string)row["LogVessel"]; } uc.RefWeek = RefWeek; uc.RefreshDay(bookdate, toff, Convert.ToDecimal(row["LogHours"]), Convert.ToDecimal(row["LogOver"]), over1, boat, Convert.ToInt32(row["LogShift"]), notebug, paycode); } catch (Exception ex) { string msg = string.Format("Error ({0}) : Employee : [{1}:{2}] {3} => TOFF Code [{4}]", ex.Message, row["EmpID"].ToString(), row["EmpName"].ToString(), bookdate, row["ToffCode"].ToString()); MessageBox.Show(msg, System.Reflection.MethodBase.GetCurrentMethod().ToString()); } } }