// converts IQueryable<timesheet> to a TimesheetDTO and stores them to List public List <TimeSheetDTO> QueryableListToDTO(List <timesheet> queryableList) { List <TimeSheetDTO> sheet = new List <TimeSheetDTO>(); foreach (var item in queryableList) { TimeSheetDTO dto = new TimeSheetDTO { User_id = item.user_id, Project_id = item.project_id, Activity_id = item.activity_id, Start_time = item.start_time, Start_date = item.start_time.ToString(), End_time = item.end_time.ToString(), Duration = item.duration ?? default(int), Description = item.description, Rate = item.rate ?? default(double), Exported = item.exported ?? default(short), Fixed_rate = item.fixed_rate ?? default(double), Hourly_rate = item.hourly_rate ?? default(double) }; sheet.Add(dto); } return(sheet); }
//protected void btnSave_Click(object sender, EventArgs e) //{ // if (ddlFile.SelectedValue == "Excel") // { // HtmlForm form = new HtmlForm(); // string attachment = "attachment; filename=aaa.xls"; // Response.ClearContent(); // Response.AddHeader("content-disposition", attachment); // Response.ContentType = "application/ms-excel"; // Response.Charset = ""; // Response.ContentEncoding = System.Text.Encoding.Unicode; // Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); // StringWriter stw = new StringWriter(); // HtmlTextWriter htextw = new HtmlTextWriter(stw); // gvDSTimeSheet.Columns[7].Visible = false; // gvDSTimeSheet.Columns[8].Visible = false; // form.Controls.Add(gvDSTimeSheet); // this.Controls.Add(form); // form.RenderControl(htextw); // Response.Write(stw.ToString()); // Response.End(); // } // if (ddlFile.SelectedValue == "Word") // { // Response.AddHeader("content-disposition", "attachment;filename=Export.doc"); // Response.Cache.SetCacheability(HttpCacheability.NoCache); // Response.ContentType = "application/vnd.word"; // Response.ClearContent(); // Response.Charset = ""; // Response.ContentEncoding = System.Text.Encoding.Unicode; // Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); // StringWriter stringWrite = new StringWriter(); // HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); // HtmlForm frm = new HtmlForm(); // gvDSTimeSheet.Columns[7].Visible = false; // gvDSTimeSheet.Columns[8].Visible = false; // gvDSTimeSheet.Parent.Controls.Add(frm); // frm.Attributes["runat"] = "server"; // frm.Controls.Add(gvDSTimeSheet); // frm.RenderControl(htmlWrite); // Response.Write(stringWrite.ToString()); // Response.End(); // } //} protected void btnThem_Click(object sender, EventArgs e) { if (this.IsPostBack) { TimeSheetDTO tsdto = new TimeSheetDTO(); int maGDV = int.Parse(drGDV.SelectedItem.Value.ToString()); tsdto.MaGDV = maGDV; string maclaim = txtThamChieu.Text; bool kt = cl.KiemTraThamChieu(maclaim); string diengiai; if (kt == true) { tsdto.ThamChieu = maclaim; tsdto.Ngay = txtNgay.Text; tsdto.IdCongTacTimeSheet = drDienGiai.SelectedItem.Value.ToString(); diengiai = drDienGiai.SelectedItem.ToString(); tsdto.ThoiLuongPhatSinh = float.Parse(txtSoGio.Text); bool them = tsdao.ThemTimeSheet(tsdto); if (them == true) { float time = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); wr.CapNhatGioTichLuy(maclaim, time); float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); bool updw = wr.CapNhatGioTichLuy(maclaim, gio); Response.Write("<script>alert('Đã thêm!');</script>"); } } } }
public bool SuaTimeSheet(TimeSheetDTO ts) { string sql = "sp_TimeSheet_Sua"; List <SqlParameter> ds = new List <SqlParameter>(); SqlParameter ma = new SqlParameter("@id", SqlDbType.Int); ma.Value = ts.ID; ds.Add(ma); SqlParameter b = new SqlParameter("@thamchieu", SqlDbType.NVarChar); b.Value = ts.ThamChieu; ds.Add(b); SqlParameter e = new SqlParameter("@macongtactimesheet", SqlDbType.VarChar); e.Value = ts.IdCongTacTimeSheet; ds.Add(e); SqlParameter ngay = new SqlParameter("@ngay", SqlDbType.VarChar); ngay.Value = ts.Ngay; ds.Add(ngay); SqlParameter f = new SqlParameter("@diengiai", SqlDbType.NVarChar); f.Value = ts.DienGiai; ds.Add(f); SqlParameter g = new SqlParameter("@phatsinh", SqlDbType.Float); g.Value = ts.ThoiLuongPhatSinh; ds.Add(g); return(SqlDataAcessHelper.exNonStoreParas(sql, ds)); }
private void Update(TimeSheetDTO timesheetDTO) { _id = timesheetDTO.Id; _name = timesheetDTO.Name; _totalHours = timesheetDTO.TotalHours; _startTime = timesheetDTO.Period.Start; _endTime = timesheetDTO.Period.End; this.Entries = new ObservableCollection <Entry>(timesheetDTO.Entries.OrderBy(x => x.Period.Start)); this.OnPropertyChanged(null);//updates all bindings }
public async void OnItemSelected(TimeSheetDTO item) { if (item == null) { return; } if (item.DayType == DayType.Vacation) { await Shell.Current.DisplayAlert("Error", "Vacation timesheet entries cannot be edited.", "OK"); return; } await Shell.Current.GoToAsync($"{nameof(TimeSheetEditPage)}?{nameof(TimeSheetDTO.TimeSheetId)}={item.TimeSheetId}"); }
public bool UpdateMa(TimeSheetDTO ts) { string sql = "sp_Timesheet_UpdateMa"; List <SqlParameter> ds = new List <SqlParameter>(); ds.Add(new SqlParameter("@id", ts.ID)); ds.Add(new SqlParameter("@idgdv", ts.MaGDV)); ds.Add(new SqlParameter("@thamchieu", ts.ThamChieu)); ds.Add(new SqlParameter("@ngay", ts.Ngay)); ds.Add(new SqlParameter("@idcongtac", ts.IdCongTacTimeSheet)); ds.Add(new SqlParameter("@diengiai", ts.DienGiai)); ds.Add(new SqlParameter("@gio", ts.ThoiLuongPhatSinh)); ds.Add(new SqlParameter("@gioissue", ts.TimeIssue)); ds.Add(new SqlParameter("@extra", ts.ExtraFee)); return(SqlDataAcessHelper.exNonStoreParas(sql, ds)); }
public List <string> GetNamesToList(TimeSheetDTO dto) // gets Customer, Project and Activity names from TimesheetDTO object { CustomerManager cmngr = new CustomerManager(); ProjectManager pmngr = new ProjectManager(); ActivityManager amngr = new ActivityManager(); string activityName = amngr.GetActivityById(dto.Activity_id); string projectName = pmngr.GetProjectNameById(dto.Project_id); string customerName = cmngr.GetCustomerNameByProjectId(dto.Project_id); List <string> names = new List <string>(); names.Add(activityName); names.Add(projectName); names.Add(customerName); return(names); }
public bool ThemTimeSheet(TimeSheetDTO ts) { string sql = "sp_TimeSheet_Them"; List <SqlParameter> ds = new List <SqlParameter>(); SqlParameter a = new SqlParameter("@magdv", SqlDbType.Int); a.Value = ts.MaGDV; ds.Add(a); SqlParameter b = new SqlParameter("@thamchieu", SqlDbType.NVarChar); b.Value = ts.ThamChieu; ds.Add(b); SqlParameter c = new SqlParameter("@ngay", SqlDbType.NVarChar); c.Value = ts.Ngay; ds.Add(c); SqlParameter e = new SqlParameter("@macongtactimesheet", SqlDbType.VarChar); e.Value = ts.IdCongTacTimeSheet; ds.Add(e); SqlParameter f = new SqlParameter("@diengiai", SqlDbType.NVarChar); f.Value = ts.DienGiai; ds.Add(f); SqlParameter g = new SqlParameter("@phatsinh", SqlDbType.Float); g.Value = ts.ThoiLuongPhatSinh; ds.Add(g); SqlParameter giothuc = new SqlParameter("@giothuc", SqlDbType.DateTime); giothuc.Value = ts.GioThuc; ds.Add(giothuc); SqlParameter extra = new SqlParameter("@extra", SqlDbType.NVarChar); extra.Value = ts.ExtraFee; ds.Add(extra); return(SqlDataAcessHelper.exNonStoreParas(sql, ds)); }
// converts TimesheetDTO to UserTimesheetDTO public UserTimesheetDTO DTOtoDTO(TimeSheetDTO firstDTO) { List <string> names = GetNamesToList(firstDTO); UserTimesheetDTO sheet = new UserTimesheetDTO { User_id = firstDTO.User_id, Project_name = names[1], Activity_name = names[0], Customer_name = names[2], Start_time = firstDTO.Start_time, Start_date = firstDTO.Start_date, End_time = firstDTO.End_time, Duration = firstDTO.Duration, Description = firstDTO.Description, Rate = firstDTO.Rate, Exported = firstDTO.Exported, Fixed_rate = firstDTO.Fixed_rate, Hourly_rate = firstDTO.Hourly_rate }; return(sheet); }
/// <summary> /// Gets the time sheet from a start date to an end date for the employee /// </summary> /// <returns></returns> public List <TimeSheetDTO> GetTimeSheet(DateTime startDate, DateTime endDate, int employeeId) { List <TimeSheetDTO> retList = new List <TimeSheetDTO>(); var timeSheets = db.Efforts.Include(i => i.Task) .Where(i => i.EmployeeId == employeeId && i.Date >= startDate && i.Date < endDate) .GroupBy(i => i.Date) .OrderBy(grp => grp.Key) .Select(grp => new TimeSheetDTO { Date = grp.Key, EffortLogs = grp.Select(j => new EffortLogDTO { EffortInHrs = j.EffortInHrs, TaskId = j.TaskId, TaskName = j.Task.Name }) }).ToList(); DateTime iStartTime = startDate; // Fills the empty effort list for the days there is no effort logged while (iStartTime < endDate) { TimeSheetDTO sheet = timeSheets.FirstOrDefault(t => t.Date == iStartTime); if (sheet == null) { sheet = new TimeSheetDTO() { Date = iStartTime }; } retList.Add(sheet); iStartTime = iStartTime.AddDays(1); } return(retList); }
public TimeSheetDTO QueryableToDTO(IQueryable <timesheet> queryableTimesheet, int userId) { TimeSheetDTO obj = (from items in db.timesheet where items.user_id == userId select new TimeSheetDTO { User_id = items.user_id, Project_id = items.project_id, Activity_id = items.activity_id, Start_time = items.start_time, Start_date = items.start_time.ToString(), End_time = items.end_time.ToString(), Duration = items.duration ?? default(int), Description = items.description, Rate = items.rate ?? default(double), Exported = items.exported ?? default(short), Fixed_rate = items.fixed_rate ?? default(double), Hourly_rate = items.hourly_rate ?? default(double) } ).FirstOrDefault(); return(obj); }
public IHttpActionResult Posttimesheet(TimeSheetDTO input) { TextResult httpResponse = new TextResult("There is already a timesheet present", message); TimesheetManager manager = new TimesheetManager(); var timesheetObject = manager.CreateTimeSheet(input.User_id, input.Start_date, input.Start_time.ToString(), input.Project_id, input.Activity_id);; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { db.timesheet.Add(timesheetObject); db.SaveChanges(); } catch { httpResponse.ChangeHTTPMessage("Failed to create timesheet", message); // HTTP response if fails to savechanges to DB return(httpResponse); } return(Ok()); }
protected void btnThem_Click(object sender, EventArgs e) { if (this.IsPostBack) { TimeSheetDTO tsdto = new TimeSheetDTO(); GiamDinhVienDAO gdv = new GiamDinhVienDAO(); int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); tsdto.MaGDV = maGDV; string tengdv = lblGiamDinhVien.Text; string maclaim = txtThamChieu.Text; bool kt = cl.KiemTraThamChieu(maclaim); float h = 0; if (txtSoGio.Text != "" && float.TryParse(txtSoGio.Text, out h)) { string diengiai = txtDienGiaiChiTiet.Text;; // string diengiaidetail = txtDienGiaiChiTiet.Text; string loaidiengiai = ""; if (diengiai != "") { tsdto.DienGiai = diengiai; } else { tsdto.DienGiai = ""; } string extr = txtEtraFee.Text; if (extr != "") { tsdto.ExtraFee = extr; } else { tsdto.ExtraFee = ""; } if (kt == true) { tsdto.ThamChieu = maclaim; tsdto.Ngay = txtNgay.Text; tsdto.IdCongTacTimeSheet = drDienGiai.SelectedItem.Value.ToString(); loaidiengiai = drDienGiai.SelectedItem.ToString(); if (int.Parse(drDienGiai.SelectedValue) != 0) { tsdto.ThoiLuongPhatSinh = float.Parse(txtSoGio.Text); tsdto.GioThuc = DateTime.Now; bool them = tsdao.ThemTimeSheet(tsdto); if (them == true) { float time = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); wr.CapNhatGioTichLuy(maclaim, time); string noidung = gdv.LayTenTheoMa(maGDV) + " created timesheet of case " + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); #region KiemTra_GuiMail float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim); bool updw = wr.CapNhatGioTichLuy(maclaim, gio); #region BodysendLA string bodyGDV = "Xin chào " + tengdv; bodyGDV += "<br/> Bạn vừa cập nhật TimeSheet mới. <br/> Thông tin TimeSheet:<br/>"; bodyGDV += "<table width='100%' align='center' style='border-bottom-color:#CCC; border-bottom-style:solid; border-bottom-width:1px; " + " border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;" + " border-right-color:#CCC; border-right-style:solid; border-right-width:1px;'>"; bodyGDV += "<tr style='background-color: #040; color:#FFF; font-weight:bold;'>"; //bodyGDV += "<th width='10%'>Giám định viên</th>"; bodyGDV += "<th width='10%'>Tham chiếu</th>"; bodyGDV += "<th width='10%'>Ngày</th>"; bodyGDV += "<th width='25%'>Diễn giải</th>"; bodyGDV += "<th width='25%'>Chi tiết</th>"; bodyGDV += "<th width='10%'>Số giờ</th>"; bodyGDV += "</tr>"; bodyGDV += "<tr style='text-align:center'>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.ThamChieu + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.Ngay + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + loaidiengiai + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + diengiai + "</td>"; bodyGDV += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.ThoiLuongPhatSinh + "</td>"; bodyGDV += "</tr>"; bodyGDV += "</table>"; #endregion #region BodyMailGiamDoc //timesheet gui giam doc string bodyGiamDoc = "Thông báo! "; bodyGiamDoc += "<br/>" + tengdv + " vừa cập nhật TimeSheet mới. <br/> Thông tin Timesheet :<br/>"; bodyGiamDoc += "<table width='100%' align='center' style='border-bottom-color:#CCC; border-bottom-style:solid; border-bottom-width:1px; " + " border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;" + " border-right-color:#CCC; border-right-style:solid; border-right-width:1px;'>"; bodyGiamDoc += "<tr style='background-color: #040; color:#FFF; font-weight:bold;'>"; bodyGiamDoc += "<th width='20%'>LA</th>"; bodyGiamDoc += "<th width='10%'>Reference</th>"; bodyGiamDoc += "<th width='10%'>Date Update</th>"; bodyGiamDoc += "<th width='10%'>Date</th>"; bodyGiamDoc += "<th width='30%'>Description</th>"; bodyGiamDoc += "<th width='10%'>Time-Spent</th>"; bodyGiamDoc += "</tr>"; bodyGiamDoc += "<tr style='text-align:center'>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tengdv + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.ThamChieu + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.GioThuc + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.Ngay + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + diengiai + "</td>"; bodyGiamDoc += "<td style ='border-top-color:#CCC; border-top-style:solid; border-top-width:1px;" + " border-left-color:#CCC; border-left-style:solid; border-left-width:1px;'>" + tsdto.ThoiLuongPhatSinh + "</td>"; bodyGiamDoc += "</tr>"; bodyGiamDoc += "</table>"; #endregion string sTo = ""; int idgdv = int.Parse(Request.Cookies["MaGDV"].Value); GiamDinhVienDAO gdvdao = new GiamDinhVienDAO(); DataTable dt = new DataTable(); dt = gdvdao.GiamDinhVienTheoMa(idgdv); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; sTo = dr[3].ToString(); } string ktmgdv = "", ktmgiamdoc = ""; int month = int.Parse(DateTime.Now.Month.ToString()); //Send_Email("*****@*****.**", sTo, "Thông báo timesheet mới", bodyGiamDoc, "[email protected],[email protected]"); //sm.KiemTraMailChinhCC(sTo, bodyGiamDoc, "Timesheet Notification", "Timesheet", "*****@*****.**"); sm.KiemTraMailChinhCC(sTo, bodyGDV, "Timesheet Notification", "Timesheet", "*****@*****.**"); #endregion ClearInputs(Page.Controls); //Response.Write("<script> window.parent.closeDialog(); </script>"); //Response.Write("<script> window.parent.location.reload();</script>"); } } else { Response.Write("<script>alert('Chưa chọn loại công tác!');</script>"); } } } else { Response.Write("<script>alert('Nhập sai định dạng giờ lẻ!');</script>"); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { TimeSheetDTO ts = new TimeSheetDTO(); ts.ID = int.Parse(lblID.Text); if (drGDV.Visible == true) { ts.MaGDV = int.Parse(drGDV.SelectedItem.Value.ToString()); } else { ts.MaGDV = int.Parse(lblID_GDV.Text); } bool kttc = cl.KiemTraThamChieu(txtThamChieu.Text); if (kttc == true) { ts.ThamChieu = txtThamChieu.Text; } else { Response.Write("<script>alert('Case no. isn't true!');</script>"); } ts.Ngay = txtNgay.Text; if (drCongTac.Visible == true) { ts.IdCongTacTimeSheet = drCongTac.SelectedItem.Value.ToString(); } else { ts.IdCongTacTimeSheet = lblID_CongTac.Text; } ts.DienGiai = txtDienGiaiChiTiet.Text; string extr = txtEtraFee.Text; if (extr != "") { ts.ExtraFee = extr; } else { ts.ExtraFee = ""; } ts.ThoiLuongPhatSinh = float.Parse(txtSoGio.Text); ts.TimeIssue = float.Parse(txtTIssue.Text); bool up = tsdao.UpdateMa(ts); if (up == true) { int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdvdao.LayTenTheoMa(maGDV) + " updated a timesheet of case " + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); Response.Write("<script> window.parent.closeDialog(); </script>"); Response.Write("<script> window.parent.location.reload();</script>"); } else { int maGDV = int.Parse(Request.Cookies["MaGDV"].Value); string noidung = gdvdao.LayTenTheoMa(maGDV) + " failed to update timesheet of case" + txtThamChieu.Text + " ."; SaveLogTracking(maGDV, noidung, txtThamChieu.Text); Response.Write("<script>alert('Update fail!');</script>"); } }