private void PostPageChanges()
        {
            int projectTimeId = (int)ViewState["projecttime_id"];
            int companiesId = int.Parse(ddlClient.SelectedValue);
            int projectId = int.Parse(ddlProject.SelectedValue);
            DateTime date_ = tkrdpDate_.SelectedDate.Value;
            string workingDetails = ""; if (ddlWorkingDetails.SelectedValue != "(Select)") workingDetails = ddlWorkingDetails.SelectedValue;

            ProjectGateway projectGateway = new ProjectGateway(new DataSet());
            projectGateway.LoadByProjectId(projectId);
            CountryGateway countryGateway = new CountryGateway(new DataSet());
            countryGateway.LoadByCountryId(projectGateway.GetCountryID(projectId));
            string location = countryGateway.GetName(projectGateway.GetCountryID(projectId));

            DateTime? startTime = null;
            if ((ddlStartTimeHour.SelectedValue.Trim() != "") && (ddlStartTimeMinute.SelectedValue.Trim() != "") )
            {
                startTime = new DateTime(date_.Year, date_.Month, date_.Day, Int32.Parse(ddlStartTimeHour.SelectedValue), Int32.Parse(ddlStartTimeMinute.SelectedValue), 0);
            }

            DateTime? endTime = null;
            if ((ddlEndTimeHour.SelectedValue.Trim() != "") && (ddlEndTimeMinute.SelectedValue.Trim() != "") )
            {
                endTime = new DateTime(date_.Year, date_.Month, date_.Day, Int32.Parse(ddlEndTimeHour.SelectedValue), Int32.Parse(ddlEndTimeMinute.SelectedValue), 0);
            }

            string work_ = ""; if (ddlTypeOfWork.SelectedValue != "(Select a Type)") work_ = ddlTypeOfWork.SelectedValue;
            string function_ = ""; if (ddlFunction.SelectedValue != "(Select a Function)") function_ = ddlFunction.SelectedValue;

            double? offset = 0; if (ddlLunch.SelectedValue != "0") offset = double.Parse(ddlLunch.SelectedValue);
            Int64? mealsCountry = null; if (ddlMealsCountry.SelectedValue != "-1") mealsCountry = Int64.Parse(ddlMealsCountry.SelectedValue);
            string mealsAllowanceType = ""; //if (cbxMealsAllowance.Checked) mealsAllowanceType = "Full Day";

            decimal mealsAllowance = MealsAllowance.GetMealsAllowance(mealsCountry, false, "Full Day");

            int? unitId = null; if (ddlUnit.SelectedValue != "-1") unitId = int.Parse(ddlUnit.SelectedValue);
            int? towedUnitId = null; if (ddlTowed.SelectedValue != "-1") towedUnitId = int.Parse(ddlTowed.SelectedValue);

            string comments = tbxComments.Text.Trim();
            bool fairWage = projectGateway.GetFairWageApplies(projectId);

            string jobClassType = ""; if (ddlJobClassType.SelectedValue != "(Select a Job Class Type)") jobClassType = ddlJobClassType.SelectedValue;

            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
            int employeeId = employeeGateway.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime projectTime = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime(projectTimeTDS);
            projectTime.Update(projectTimeId, companiesId, projectId, date_, startTime, endTime, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, unitId, towedUnitId, comments, work_, function_, fairWage, jobClassType, employeeId);
        }
        private void PostPageChanges()
        {
            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
            int employeeId = employeeGateway.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

            projectTimeTDSToSave = new ProjectTimeTDS();
            LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime projectTime = new LiquiForce.LFSLive.BL.LabourHours.ProjectTime.ProjectTime(projectTimeTDS);
            projectTime.Insert(projectTimeTDSToSave, employeeId);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="projectTimeTDSToSave">projectTimeTDSToSave</param>
        public void Insert(ProjectTimeTDS projectTimeTDSToSave, int createdById)
        {
            foreach (ProjectTimeTDS.LFS_PROJECT_TIME_TEMPRow projectTimeRow in ((ProjectTimeTDS)Data).LFS_PROJECT_TIME_TEMP)
            {
                if (!projectTimeRow.Deleted)
                {
                    int employeeId = projectTimeRow.EmployeeID;
                    int companiesId = projectTimeRow.CompaniesID;
                    int projectId = projectTimeRow.ProjectID;
                    DateTime date_ = projectTimeRow.Date_;
                    DateTime? startTime = null;
                    if (!projectTimeRow.IsStartTimeNull())
                    {
                        string[] startTimeSplit = projectTimeRow.StartTime.Split(':');
                        int startTimeHour = Int32.Parse(startTimeSplit[0].ToString());
                        int startTimeMinute = Int32.Parse(startTimeSplit[1].ToString());
                        startTime = new DateTime(date_.Year, date_.Month, date_.Day, startTimeHour, startTimeMinute, 0);
                    }
                    DateTime? endTime = null;
                    if (!projectTimeRow.IsEndTimeNull())
                    {
                        string[] endTimeSplit = projectTimeRow.EndTime.Split(':');
                        int endTimeHour = Int32.Parse(endTimeSplit[0].ToString());
                        int endTimeMinute = Int32.Parse(endTimeSplit[1].ToString());
                        endTime = new DateTime(date_.Year, date_.Month, date_.Day, endTimeHour, endTimeMinute, 0);

                        if (endTime < startTime)
                        {
                            endTime.Value.AddDays(1);
                        }
                    }
                    double? offset = null; if (!projectTimeRow.IsOffsetNull()) offset = projectTimeRow.Offset;
                    string workingDetails = ""; if (!projectTimeRow.IsWorkingDetailsNull()) workingDetails = projectTimeRow.WorkingDetails;
                    string location = ""; if (!projectTimeRow.IsLocationNull()) location = projectTimeRow.Location;
                    Int64? mealsCountry = null; if (!projectTimeRow.IsMealsCountryNull()) mealsCountry = projectTimeRow.MealsCountry;
                    string mealsAllowanceType = ""; if (!projectTimeRow.IsMealsAllowanceTypeNull()) mealsAllowanceType = projectTimeRow.MealsAllowanceType;
                    decimal mealsAllowance = projectTimeRow.MealsAllowance;
                    string comments = ""; if (!projectTimeRow.IsCommentsNull()) comments = projectTimeRow.Comments;
                    int? unitId = null; if (!projectTimeRow.IsUnitIDNull()) unitId = projectTimeRow.UnitID;
                    int? towedUnitId = null; if (!projectTimeRow.IsTowedUnitIDNull()) towedUnitId = projectTimeRow.TowedUnitID;
                    string projectTimeState = projectTimeRow.ProjectTimeState;
                    bool deleted = projectTimeRow.Deleted;
                    string work_ = ""; if (!projectTimeRow.IsWork_Null()) work_ = projectTimeRow.Work_;
                    string function_ = ""; if (!projectTimeRow.IsFunction_Null()) function_ = projectTimeRow.Function_;
                    bool fairWage = projectTimeRow.FairWage;
                    string jobClassType = ""; if (!projectTimeRow.IsJobClassTypeNull()) jobClassType = projectTimeRow.JobClassType;

                    ProjectTime projectTimeToSave = new ProjectTime(Data);
                    projectTimeToSave.Insert(employeeId, companiesId, projectId, date_, startTime, endTime, offset, workingDetails, location, mealsCountry, mealsAllowanceType, mealsAllowance, unitId, towedUnitId, projectTimeState, comments, work_, function_, fairWage, jobClassType, createdById);
                }
            }
        }