Beispiel #1
0
        protected void saveLoggedInfo_OnClick(object sender, EventArgs e)
        {
            var query        = Request.QueryString;
            var projId       = Convert.ToInt64(query.Get("id"));
            var id           = Convert.ToInt64(Session["ID"]);
            var workLogId    = 0L;
            var selectedDate = Request.Form[start_period.UniqueID];

            if (!string.IsNullOrEmpty(selectedDate))
            {
                var convertDate = CovertToDateTime(selectedDate);
                var logFound    = _projectService.GetWorkLogByProjIdAndDate(projId, convertDate);

                if (!logFound)
                {
                    var log = new WorkLog
                    {
                        date_logged = convertDate,
                        proj_id     = (int)projId,
                        user_id     = (int)id
                    };

                    _insendluEntities.WorkLogs.Add(log);
                    var check = _insendluEntities.SaveChanges();

                    if (check == 1)
                    {
                        workLogId = log.id;
                    }


                    //Accommodation
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(accCost.Text))
                    {
                        var date   = Request.Form[start_period.UniqueID];
                        var startP = CovertToDateTime(date);

                        var accomCost     = Convert.ToInt32(accCost.Text);
                        var accomLocation = accLocation.Text;

                        var accommodation = new Accommodation
                        {
                            cost       = accomCost,
                            start_date = convertDate,
                            location   = accomLocation,
                            worklog_id = (int)workLogId,
                            project_id = (int)projId
                        };

                        _insendluEntities.Accommodations.Add(accommodation);

                        _insendluEntities.SaveChanges();
                    }
                    //Vehicle Details
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(vCost.Text))
                    {
                        var date      = Request.Form[start_period.UniqueID];
                        var vStartDat = CovertToDateTime(date);

                        var vDetails = vType.Text;
                        var vMill    = vMilage.Text;
                        var vCos     = Convert.ToInt32(vCost.Text);

                        var vehicle = new Vehicle
                        {
                            cost       = vCos,
                            start_date = convertDate,
                            mileage    = vMill,
                            type       = vDetails,
                            worklog_id = (int)workLogId,
                            project_id = (int)projId
                        };

                        _insendluEntities.Vehicles.Add(vehicle);
                        _insendluEntities.SaveChanges();
                    }

                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(empCostPerDay.Text))
                    {
                        //Employees
                        var date         = Request.Form[start_period.UniqueID];
                        var empStartDate = CovertToDateTime(date);

                        var emploType = empType.Text;
                        var numOfEmp  = empNumber.Text;
                        var empCost   = Convert.ToInt32(empCostPerDay.Text);

                        var employees = new Employee
                        {
                            cost          = empCost,
                            employee_type = emploType,

                            no_of_employees = numOfEmp,
                            start_date      = convertDate,
                            worklog_id      = (int)workLogId,
                            project_id      = (int)projId
                        };

                        _insendluEntities.Employees.Add(employees);
                        _insendluEntities.SaveChanges();
                    }

                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(matCost.Text))
                    {
                        //Print Material
                        var date     = Request.Form[start_period.UniqueID];
                        var matStart = CovertToDateTime(date);

                        var matQua  = matQuantity.Text;
                        var matName = materialName.Text;
                        var matCos  = Convert.ToInt32(matCost.Text);

                        var material = new PrintMaterial
                        {
                            worklog_id = (int)workLogId,
                            cost       = matCos,
                            start_date = convertDate,
                            project_id = (int)projId,
                            name       = matName,
                            quantity   = matQua
                        };

                        _insendluEntities.PrintMaterials.Add(material);
                        _insendluEntities.SaveChanges();
                    }
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(refCost.Text))
                    {
                        //Refreshments
                        var date     = Request.Form[start_period.UniqueID];
                        var refStart = CovertToDateTime(date);

                        var refCostAmount = Convert.ToInt32(refCost.Text);

                        var refreshments = new Refreshment
                        {
                            cost = refCostAmount,

                            start_date = convertDate,
                            worklog_id = (int)workLogId,
                            project_id = (int)projId
                        };

                        _insendluEntities.Refreshments.Add(refreshments);
                        _insendluEntities.SaveChanges();
                    }
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(telCost.Text))
                    {
                        //Telephone
                        var date     = Request.Form[start_period.UniqueID];
                        var telStart = CovertToDateTime(date);

                        var telCostAmount = Convert.ToInt32(telCost.Text);

                        var telephone = new Telephone
                        {
                            cost       = telCostAmount,
                            start_date = convertDate,
                            worklog_id = (int)workLogId,
                            project_id = (int)projId
                        };

                        _insendluEntities.Telephones.Add(telephone);
                        _insendluEntities.SaveChanges();
                    }
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(wifiCost.Text))
                    {
                        //WIFI
                        var date      = Request.Form[start_period.UniqueID];
                        var wifiStart = CovertToDateTime(date);

                        var wifiTotalCost = Convert.ToInt32(wifiCost.Text);

                        var wifi = new Wifi
                        {
                            cost       = wifiTotalCost,
                            worklog_id = (int)workLogId,
                            start_date = convertDate,
                            project_id = (int)projId
                        };

                        _insendluEntities.Wifis.Add(wifi);
                        _insendluEntities.SaveChanges();
                    }
                    if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(fieldWorkDrop.Value))
                    {
                        //FIELD WORK STATISTICS
                        var date       = Request.Form[start_period.UniqueID];
                        var fieldStart = CovertToDateTime(date);

                        var fieldWork = fieldWorkDrop.Value;

                        var fieldWorkStarts = new FieldWorkStatistic
                        {
                            name       = fieldWork,
                            worklog_id = (int)workLogId,
                            start_date = convertDate,
                            project_id = (int)projId
                        };

                        _insendluEntities.FieldWorkStatistics.Add(fieldWorkStarts);
                        _insendluEntities.SaveChanges();
                    }
                    Response.Redirect("ProjectTimeLine.aspx?id=" + projId);
                }
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Already Logged work for this day')", true);
            }
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Please select a date')", true);
        }
Beispiel #2
0
        protected void saveLoggedInfo_OnClick(object sender, EventArgs e)
        {
            var query   = Request.QueryString;
            var workLog = Convert.ToInt64(query.Get("id"));
            var id      = Convert.ToInt64(Session["ID"]);

            //Accommodation
            if (!string.IsNullOrEmpty(Request.Form[start_period.UniqueID]) && !string.IsNullOrEmpty(Request.Form[end_period.UniqueID]))
            {
                var startP        = Convert.ToDateTime(Request.Form[start_period.UniqueID]).Date;
                var endP          = Convert.ToDateTime(Request.Form[end_period.UniqueID]).Date;
                var accomCost     = Convert.ToInt32(accCost.Text);
                var accomLocation = accLocation.Text;

                var accommodation = new Accommodation()
                {
                    cost       = accomCost,
                    end_start  = endP,
                    start_date = startP,
                    location   = accomLocation,
                    worklog_id = (int)workLog
                };

                _insendluEntities.Accommodations.Add(accommodation);

                _insendluEntities.SaveChanges();
            }
            //Vehicle Details
            if (!string.IsNullOrEmpty(Request.Form[vStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[vEndDate.UniqueID]))
            {
                var vStartDat = Convert.ToDateTime(Request.Form[vStartDate.UniqueID]).Date;
                var vEndDat   = Convert.ToDateTime(Request.Form[vEndDate.UniqueID]).Date;
                var vDetails  = vType.Text;
                var vMill     = vMilage.Text;
                var vCos      = Convert.ToInt32(vCost.Text);

                var vehicle = new Vehicle()
                {
                    cost       = vCos,
                    end_start  = vEndDat,
                    start_date = vStartDat,
                    mileage    = vMill,
                    type       = vDetails,
                    worklog_id = (int)workLog
                };

                _insendluEntities.Vehicles.Add(vehicle);
                _insendluEntities.SaveChanges();
            }

            if (!string.IsNullOrEmpty(Request.Form[empStart.UniqueID]) && !string.IsNullOrEmpty(Request.Form[empEndDate.UniqueID]))
            {
                //Employees
                var empStartDate = Convert.ToDateTime(Request.Form[empStart.UniqueID]).Date;
                var empEnd       = Convert.ToDateTime(Request.Form[empEndDate.UniqueID]).Date;
                var emploType    = empType.Text;
                var numOfEmp     = empNumber.Text;
                var empCost      = Convert.ToInt32(empCostPerDay.Text);

                var employees = new Employee()
                {
                    cost            = empCost,
                    employee_type   = emploType,
                    end_start       = empEnd,
                    no_of_employees = numOfEmp,
                    start_date      = empStartDate,
                    worklog_id      = (int)workLog
                };

                _insendluEntities.Employees.Add(employees);
                _insendluEntities.SaveChanges();
            }

            if (!string.IsNullOrEmpty(Request.Form[matStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[matEndDate.UniqueID]))
            {
                //Print Material
                var matStart = Convert.ToDateTime(Request.Form[matStartDate.UniqueID]).Date;
                var matEnd   = Convert.ToDateTime(Request.Form[matEndDate.UniqueID]).Date;
                var matQua   = matQuantity.Text;
                var matName  = materialName.Text;
                var matCos   = Convert.ToInt32(matCost.Text);

                var material = new PrintMaterial()
                {
                    worklog_id = (int)workLog,
                    cost       = matCos,
                    start_date = matStart,
                    end_start  = matEnd,
                    name       = matName,
                    quantity   = matQua
                };

                _insendluEntities.PrintMaterials.Add(material);
                _insendluEntities.SaveChanges();
            }
            if (!string.IsNullOrEmpty(Request.Form[refStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[refEndDate.UniqueID]))
            {
                //Refreshments
                var refStart      = Convert.ToDateTime(Request.Form[refStartDate.UniqueID]).Date;
                var refEnd        = Convert.ToDateTime(Request.Form[refEndDate.UniqueID]).Date;
                var refCostAmount = Convert.ToInt32(refCost.Text);

                var refreshments = new Refreshment()
                {
                    cost       = refCostAmount,
                    end_start  = refEnd,
                    start_date = refStart,
                    worklog_id = (int)workLog
                };

                _insendluEntities.Refreshments.Add(refreshments);
                _insendluEntities.SaveChanges();
            }
            if (!string.IsNullOrEmpty(Request.Form[telStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[telEndDate.UniqueID]))
            {
                //Telephone
                var telStart      = Convert.ToDateTime(Request.Form[telStartDate.UniqueID]).Date;
                var telEndDat     = Convert.ToDateTime(Request.Form[telEndDate.UniqueID]).Date;
                var telCostAmount = Convert.ToInt32(telCost.Text);

                var telephone = new Telephone()
                {
                    cost       = telCostAmount,
                    end_start  = telEndDat,
                    start_date = telStart,
                    worklog_id = (int)workLog
                };

                _insendluEntities.Telephones.Add(telephone);
                _insendluEntities.SaveChanges();
            }
            if (!string.IsNullOrEmpty(Request.Form[wifiStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[wifiEndDate.UniqueID]))
            {
                //WIFI
                var wifiStart     = Convert.ToDateTime(Request.Form[wifiStartDate.UniqueID]).Date;
                var wifiEnd       = Convert.ToDateTime(Request.Form[wifiEndDate.UniqueID]).Date;
                var wifiTotalCost = Convert.ToInt32(wifiCost.Text);

                var wifi = new Wifi()
                {
                    cost       = wifiTotalCost,
                    worklog_id = (int)workLog,
                    start_date = wifiStart,
                    end_start  = wifiEnd
                };

                _insendluEntities.Wifis.Add(wifi);
                _insendluEntities.SaveChanges();
            }
            if (!string.IsNullOrEmpty(Request.Form[fieldStartDate.UniqueID]) && !string.IsNullOrEmpty(Request.Form[fieldEndDate.UniqueID]))
            {
                //FIELD WORK STATISTICS
                var fieldStart = Convert.ToDateTime(Request.Form[fieldStartDate.UniqueID]).Date;
                var fieldEnd   = Convert.ToDateTime(Request.Form[fieldEndDate.UniqueID]).Date;
                var fieldWork  = fieldWorkDrop.Value;

                var fieldWorkStarts = new FieldWorkStatistic()
                {
                    name       = fieldWork,
                    worklog_id = (int)workLog,
                    start_date = fieldStart,
                    end_date   = fieldEnd
                };

                _insendluEntities.FieldWorkStatistics.Add(fieldWorkStarts);
                _insendluEntities.SaveChanges();
            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Information saved Successfully')", true);

            Response.Redirect("Proposals.aspx");
        }