public override void SaveModuleObjects() { HRTimeSheetsInfo timeSheet = (HRTimeSheetsInfo)MainObject; //Save employee time sheet list EmployeeTimeSheetsList.SaveItemObjects(); //Create entry for time sheet HRTimeSheetEntrysController objTimeSheetEntrysController = new HRTimeSheetEntrysController(); HREmployeeTimeSheetOTDetailsController objEmployeeTimeSheetOTDetailsController = new HREmployeeTimeSheetOTDetailsController(); foreach (HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo in EmployeeTimeSheetsList) { objTimeSheetEntrysController.DeleteByForeignColumn("FK_HREmployeeTimeSheetID", objEmployeeTimeSheetsInfo.HREmployeeTimeSheetID); foreach (HRTimeSheetEntrysInfo entry in objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList) { if (entry.FK_HRTimeSheetParamID == 0) { continue; } entry.FK_HRTimeSheetID = timeSheet.HRTimeSheetID; entry.FK_HREmployeeTimeSheetID = objEmployeeTimeSheetsInfo.HREmployeeTimeSheetID; objTimeSheetEntrysController.CreateObject(entry); } objEmployeeTimeSheetOTDetailsController.DeleteByForeignColumn("FK_HREmployeeTimeSheetID", objEmployeeTimeSheetsInfo.HREmployeeTimeSheetID); foreach (HREmployeeTimeSheetOTDetailsInfo obj in objEmployeeTimeSheetsInfo.HREmployeeTimeSheetOTDetailsList) { obj.FK_HREmployeeTimeSheetID = objEmployeeTimeSheetsInfo.HREmployeeTimeSheetID; objEmployeeTimeSheetOTDetailsController.CreateObject(obj); } } }
public override void SetDefaultMainObject() { base.SetDefaultMainObject(); HRTimeSheetsInfo objTimeSheetsInfo = (HRTimeSheetsInfo)MainObject; objTimeSheetsInfo.HRTimeSheetDate = DateTime.Now; objTimeSheetsInfo.HRTimeSheetFromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); objTimeSheetsInfo.HRTimeSheetToDate = VinaUtil.GetMonthEndDate(DateTime.Now); objTimeSheetsInfo.HRTimeSheetType = TimeSheetType.Day.ToString(); objTimeSheetsInfo.HRTimeSheetStatus = TimeSheetStatus.New.ToString(); objTimeSheetsInfo.FK_HREmployeeID = VinaApp.CurrentUserInfo.FK_HREmployeeID; }
public void SetEmployeeTimeSheetValue(HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo) { HRTimeSheetsInfo timeSheet = (HRTimeSheetsInfo)MainObject; List <string> employeeTimeSheetValueList = new List <string> { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; foreach (HRTimeSheetEntrysInfo timeSheetEntry in objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList) { if (timeSheetEntry.HRTimeSheetEntryDate.Date >= timeSheet.HRTimeSheetFromDate.Date && timeSheetEntry.HRTimeSheetEntryDate.Date <= timeSheet.HRTimeSheetToDate.Date) { int index = (int)(timeSheetEntry.HRTimeSheetEntryDate.Date - timeSheet.HRTimeSheetFromDate.Date).TotalDays + 1; string timeSheetParamNo = string.Empty; HRTimeSheetParamsInfo objTimeSheetParamsInfo = TimeSheetParams.Where(t => t.HRTimeSheetParamID == timeSheetEntry.FK_HRTimeSheetParamID).FirstOrDefault(); if (objTimeSheetParamsInfo != null) { timeSheetParamNo = objTimeSheetParamsInfo.HRTimeSheetParamNo; } if (!string.IsNullOrEmpty(timeSheetParamNo)) { if (string.IsNullOrEmpty(employeeTimeSheetValueList[index - 1].Trim())) { employeeTimeSheetValueList[index - 1] = timeSheetParamNo; } else { employeeTimeSheetValueList[index - 1] += String.Format(", {0}", timeSheetParamNo); } } } } VinaDbUtil dbUtil = new VinaDbUtil(); int numDays = ((TimeSheetModule)Module).NumOfDayInMonth(); if (numDays > 31) { numDays = 31; } for (int i = 1; i <= numDays; i++) { String propertyName = String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString()); dbUtil.SetPropertyValue(objEmployeeTimeSheetsInfo, propertyName, employeeTimeSheetValueList[i - 1]); } }
public void CompleteTransaction() { HRTimeSheetsInfo objTimeSheetsInfo = (HRTimeSheetsInfo)MainObject; HRTimeSheetsController objTimeSheetsController = new HRTimeSheetsController(); HRTimeSheetsInfo objReferrenceTimeSheetsInfo = (HRTimeSheetsInfo)objTimeSheetsController.GetObjectByID(objTimeSheetsInfo.HRTimeSheetID); if (objReferrenceTimeSheetsInfo != null) { objReferrenceTimeSheetsInfo.HRTimeSheetStatus = TimeSheetStatus.Approved.ToString(); objTimeSheetsController.UpdateObject(objReferrenceTimeSheetsInfo); objTimeSheetsInfo.HRTimeSheetStatus = TimeSheetStatus.Approved.ToString(); UpdateMainObjectBindingSource(); } }
/// <summary> /// Initialize BandedGridView /// </summary> /// <param name="gridView"></param> /// <returns></returns> private BandedGridView InitializeBandedGridView(GridView gridView) { TimeSheetEntities entity = (TimeSheetEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity; HRTimeSheetsInfo objTimeSheetsInfo = (HRTimeSheetsInfo)entity.MainObject; //Creat a banded grid view BandedGridView bandedView = new BandedGridView(); GridBand gridBand1 = new GridBand(); GridBand gridBand2 = new GridBand(); GridBand gridBand3 = new GridBand(); bandedView.Bands.AddRange(new DevExpress.XtraGrid.Views.BandedGrid.GridBand[] { gridBand1, gridBand2, gridBand3 }); for (int i = 0; i < gridView.Columns.Count; i++) { bandedView.Columns.AddRange(new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[] { ConvertToBandedGridColumn(gridView.Columns[i], false) }); } bandedView.GridControl = this; bandedView.Name = "bandedGridView1"; bandedView.OptionsCustomization.AllowFilter = false; bandedView.OptionsView.ShowAutoFilterRow = true; bandedView.OptionsView.ColumnAutoWidth = false; bandedView.OptionsView.ShowGroupPanel = false; bandedView.OptionsCustomization.AllowSort = true; bandedView.OptionsView.ShowChildrenInGroupPanel = false; bandedView.OptionsView.ShowDetailButtons = false; //GridBand1 gridBand1.Caption = "Thông tin nhân viên"; gridBand1.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; gridBand1.Name = "gridBand1"; //GridBand2 gridBand2.Caption = "Danh sách ngày"; gridBand2.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; gridBand2.Name = "gridBand2"; //GridBand3 gridBand3.Caption = "Quy ra công"; gridBand3.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; gridBand3.Name = "gridBand3"; // Assigning columns to bands GridColumn column = gridView.Columns["HREmployeeCardNumber"]; if (column != null) { CreateNewColumn(column, gridBand1, false); } column = gridView.Columns["HREmployeeName"]; if (column != null) { CreateNewColumn(column, gridBand1, false); } column = gridView.Columns["HRDepartmentRoomName"]; if (column != null) { CreateNewColumn(column, gridBand1, false); } //int dateStart = objTimeSheetsInfo.HRTimeSheetFromDate.Day; for (int i = 1; i <= 31; i++) { column = gridView.Columns[String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString())]; if (column != null) { CreateNewColumn(column, gridBand2, false); } } column = gridView.Columns["HREmployeeTimeSheetWorkingQty"]; if (column != null) { CreateNumericColumn(column, gridBand3, false, "n1"); } if (WorkingShiftList != null) { WorkingShiftList.ForEach(o => { column = gridView.Columns["CONG" + o.ADWorkingShiftID.ToString()]; if (column != null) { column.Caption = "Công " + o.ADWorkingShiftName; CreateNumericColumn(column, gridBand3, false, "n5"); } }); } HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController(); List <HRTimeSheetParamsInfo> OTFactorlist = objTimeSheetParamsController.GetDistinctOTTimeSheetParamsList(); foreach (var item in OTFactorlist) { column = gridView.Columns[item.HRTimeSheetParamValue2.ToString()]; if (column != null) { column.Caption = "TC HS " + item.HRTimeSheetParamValue2.ToString(); CreateNumericColumn(column, gridBand3, false, "n3"); } } column = gridView.Columns["HREmployeeTimeSheetOTQty"]; if (column != null) { CreateNumericColumn(column, gridBand3, false, "n3"); } column = gridView.Columns["HREmployeeTimeSheetLeaveQty"]; if (column != null) { CreateNumericColumn(column, gridBand3, false, "n1"); } column = gridView.Columns["HREmployeeTimeSheetNghiLe"]; if (column != null) { CreateNumericColumn(column, gridBand3, false, "n1"); } bandedView.CustomDrawCell += new RowCellCustomDrawEventHandler(BandedView_CustomDrawCell); bandedView.CellValueChanged += new CellValueChangedEventHandler(BandedView_CellValueChanged); bandedView.RowClick += new RowClickEventHandler(BandedView_RowClick); bandedView.KeyUp += new KeyEventHandler(BandedView_KeyUp); return(bandedView); }
protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView) { base.AddColumnsToGridView(strTableName, gridView); GridColumn column = new GridColumn(); column.Caption = "Mã nhân viên"; column.FieldName = "HREmployeeNo"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Mã ID"; column.FieldName = "HREmployeeCardNumber"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Chi nhánh"; column.FieldName = "BRBranchName"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Bộ phận"; column.FieldName = "HRDepartmentRoomName"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Phòng ban"; column.FieldName = "HRDepartmentName"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Tên nhân viên"; column.FieldName = "HREmployeeName"; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Tổ"; column.FieldName = "HRDepartmentRoomGroupItemName"; gridView.Columns.Add(column); int numDays = ((TimeSheetModule)Screen.Module).NumOfDayInMonth(); TimeSheetEntities entity = (TimeSheetEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity; HRTimeSheetsInfo objTimeSheetsInfo = (HRTimeSheetsInfo)entity.MainObject; for (int i = 1; i <= numDays; i++) { GridColumn columnDays = new GridColumn(); DateTime dt = objTimeSheetsInfo.HRTimeSheetFromDate.Date.AddDays(i - 1); columnDays.Caption = dt.ToString("dd/MM"); bool isDayOfWeek = (VinaApp.IsEndOfWeek(dt.DayOfWeek)); if (isDayOfWeek) { columnDays.Caption = "CN (" + dt.ToString("dd/MM") + ")"; } columnDays.FieldName = String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString()); gridView.Columns.Add(columnDays); } HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController(); List <HRTimeSheetParamsInfo> OTFactorlist = objTimeSheetParamsController.GetDistinctOTTimeSheetParamsList(); foreach (var item in OTFactorlist) { column = new GridColumn(); column.Caption = "TC HS " + item.HRTimeSheetParamValue2.ToString(); column.FieldName = item.HRTimeSheetParamValue2.ToString(); column.Tag = item.HRTimeSheetParamValue2; gridView.Columns.Add(column); } if (WorkingShiftList != null) { WorkingShiftList.ForEach(o => { column = new GridColumn(); column.Caption = "Công " + o.ADWorkingShiftName; column.FieldName = "CONG" + o.ADWorkingShiftID.ToString(); column.Tag = "CONG" + o.ADWorkingShiftID.ToString(); gridView.Columns.Add(column); }); } }
public override void InitMainObject() { MainObject = new HRTimeSheetsInfo(); SearchObject = new HRTimeSheetsInfo(); }