Beispiel #1
0
        protected void changeStatus_OnClick(object sender, EventArgs e)
        {
            //var id = _projId;
            var stats    = 0;
            var selected = String.Empty;
            var taskId   = Convert.ToInt32(tasks.SelectedValue);

            foreach (ListItem item in statusDropdown.Items)
            {
                if (item.Selected)
                {
                    selected = item.Value;
                    stats    = Status(selected);
                    break;
                }
            }
            var taskStatus = Convert.ToInt32(stats);
            var task       = _insendluEntities.Tasks.Single(x => x.id == taskId);

            task.status = taskStatus;
            _insendluEntities.Entry(task).State = EntityState.Modified;
            _insendluEntities.SaveChanges();

            SetTasks(_user);
        }
Beispiel #2
0
        protected void changeStatus_OnClick(object sender, EventArgs e)
        {
            var id       = _projId;
            var stats    = 0;
            var selected = String.Empty;

            foreach (ListItem item in statusDropdown.Items)
            {
                if (item.Selected)
                {
                    selected = item.Value;
                    stats    = Status(selected);
                    break;
                }
            }

            var project = (from pro in _insendluEntities.Projects
                           where pro.id == id
                           select pro).SingleOrDefault();

            if (project != null)
            {
                project.status = stats;

                var check = _insendluEntities.SaveChanges();

                if (check == 1)
                {
                    statusLabel.Text      = string.Format("Project {0}'s status has successfully been updated to '{1}' ", project.name, selected);
                    statusLabel.Visible   = true;
                    statusLabel.ForeColor = Color.Chartreuse;
                }
            }
        }
        public int AddNewProject(Project proj)
        {
            var project = new Project()
            {
                created_at  = proj.created_at,
                modified_at = proj.modified_at,
                description = proj.description,
                status      = proj.status,
                proj_cat_id = proj.proj_cat_id,
                name        = proj.name
            };

            _insendluEntities.Projects.Add(project);

            return(_insendluEntities.SaveChanges());
        }
Beispiel #4
0
        protected void projection_OnClick(object sender, EventArgs e)
        {
            var query = Request.QueryString;
            var id    = Convert.ToInt32(query.Get("id"));

            var userId = Convert.ToInt32(Session["ID"]);
            var projId = id;
            //save project projection
            var accomo   = accomodation.Text;
            var vehCle   = vehicle.Text;
            var empl     = employees.Text;
            var tel      = telephone.Text;
            var dataWifi = data.Text;
            var refresh  = refreshment.Text;
            var printM   = printmaterial.Text;

            var projections = new ProjectProjection();

            if (!string.IsNullOrEmpty(accomo))
            {
                projections.accomodation = accomo;
            }
            if (!string.IsNullOrEmpty(vehCle))
            {
                projections.vehicle = vehCle;
            }
            if (!string.IsNullOrEmpty(empl))
            {
                projections.employees = empl;
            }
            if (!string.IsNullOrEmpty(tel))
            {
                projections.telephone = tel;
            }
            if (!string.IsNullOrEmpty(dataWifi))
            {
                projections.wifi_data = dataWifi;
            }
            if (!string.IsNullOrEmpty(refresh))
            {
                projections.refreshments = refresh;
            }
            if (!string.IsNullOrEmpty(printM))
            {
                projections.print_material = printM;
            }

            projections.created_at  = DateTime.Today;
            projections.modified_at = DateTime.Today;
            projections.proj_id     = projId;
            projections.user_id     = userId;

            _insendluEntities.ProjectProjections.Add(projections);
            _insendluEntities.SaveChanges();
        }
Beispiel #5
0
        protected void Send_OnClick(object sender, EventArgs e)
        {
            var email = forgotPassemail.Value;
            var user  = _insendluEntities.Users.Single(x => x.email == email);

            if (user != null)
            {
                user.password = null;
                _insendluEntities.Entry(user).State = EntityState.Modified;
                _insendluEntities.SaveChanges();

                var tempPass      = user.name + user.surname + "$";
                var path          = Server.MapPath("~/Templates/forgotpasswordtemplate.html");
                var encryptedPass = _encryptor.Encrypt(tempPass);
                user.temporary_password             = encryptedPass;
                _insendluEntities.Entry(user).State = EntityState.Modified;
                _insendluEntities.SaveChanges();

                _emailService.SendEmail(email, encryptedPass, path, user.name);
            }
        }
Beispiel #6
0
        protected void Update_OnClick(object sender, EventArgs e)
        {
            var id           = Convert.ToInt64(Session["ID"]);
            var modification = DateTime.Now;

            var comp      = companyBackground.Content;
            var execSumm  = execSummary.Content;
            var costP     = costPlan.Content;
            var methodol  = propMethodology.Content;
            var poli      = riskanalysis.Content;
            var projDesc  = descriptionPro.Text;
            var projName  = projectName.Text;
            var conlusion = conclusion.Content;

            var proj = _projectService.GetProject(id);

            proj.description = projDesc;
            proj.name        = projName;
            proj.conclusion  = conlusion;
            proj.modified_at = modification;

            _insendluEntities.Entry(proj).State = System.Data.Entity.EntityState.Modified;
            _insendluEntities.SaveChanges();

            var execSummar = (from exec in _insendluEntities.ExecutiveSummaries
                              where exec.proj_id == id
                              select exec).SingleOrDefault();

            UpdateExecSummary(execSumm, execSummar, modification);

            var plan = (from cost in _insendluEntities.ProjectCostPlans
                        where cost.proj_id == id
                        select cost).SingleOrDefault();

            UpdateCostPlan(costP, plan, modification);

            var company = (from compan in _insendluEntities.Companies
                           where compan.proj_id == id
                           select compan).SingleOrDefault();

            UpdateCompany(comp, company, modification);

            var methodology = (from meth in _insendluEntities.ProjectMethodologies
                               where meth.proj_id == id
                               select meth).SingleOrDefault();

            UpdateProjectMethodology(methodol, methodology, modification);

            var policy = (from polic in _insendluEntities.ProjectPolicies
                          where polic.proj_id == id
                          select polic).SingleOrDefault();

            UpdateprojectPolicy(poli, policy, modification);


            SaveProject(proj);

            Response.Redirect("~/ActiveProjects.aspx");
        }
        protected void Assign_OnClick(object sender, EventArgs e)
        {
            var project = projectList.SelectedItem.Text;

            var userLis = Request.Form[userList.UniqueID];
            var list    = new List <string>();

            if (!string.IsNullOrEmpty(userLis))
            {
                list = userLis.Split(',').ToList();
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Please select user to assign to project')", true);
                return;
            }
            var usList = new List <int>(list.Count);
            var report = string.Empty;

            for (var i = 0; i < list.Count; i++)
            {
                usList.Add(Convert.ToInt32(list[i]));
            }

            var proj = _projectService.GetProjectByName(project);

            foreach (var selectedUser in usList)
            {
                var userProj = new User_Project
                {
                    created_at  = DateTime.Now,
                    modified_at = DateTime.Now,
                    proj_id     = (int)proj.id,
                    user_id     = selectedUser
                };

                var userSelected = _projectService.GetUserById(selectedUser);
                _insendluEntities.User_Project.Add(userProj);
                var hidd = _insendluEntities.SaveChanges();

                report += string.Format("{0}, ", userSelected.name);
            }

            report += string.Format(" has / have been added to proposal {0}", project);

            GetActiveProposals();
            GetUserList();

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('" + report + "')", true);
        }
        protected void schedule_OnClick(object sender, EventArgs e)
        {
            var departmentName = department.Value;
            var projDuration   = Convert.ToInt32(duration.Value);

            var project = GetProject();

            project.department_name = departmentName;
            project.duration        = projDuration;

            var check = _insendluEntities.SaveChanges();

            Response.Redirect("Approved.aspx?id=" + project.id);
        }
        private void UserUpdate(int id)
        {
            var user = (from users in _insendluEntities.Users
                        where users.id == id
                        select users).SingleOrDefault();

            if (user != null)
            {
                var stats = (int)EntityStatus.InActive;
                user.status = stats;

                _insendluEntities.SaveChanges();
            }
        }
        protected void schedule_OnClick(object sender, EventArgs e)
        {
            var sectorId          = drpSector.SelectedIndex;
            var projDurationStart = Convert.ToDateTime(durationStartDate.Text);
            var projDurationend   = Convert.ToDateTime(durationEndDate.Text);

            var project = GetProject();

            project.sector_id  = sectorId;
            project.start_date = projDurationStart;
            project.end_date   = projDurationend;

            var check = _insendluEntities.SaveChanges();

            Response.Redirect("Approved.aspx?id=" + project.id);
        }
Beispiel #11
0
        protected void ButtonUpload_Click(object sender, EventArgs e)
        {
            var id = Convert.ToInt64(Session["ID"]);

            if (FileUpload1.HasFile && FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
            {
                HttpPostedFile file        = FileUpload1.PostedFile;//retrieve the HttpPostedFile object
                var            buffer      = new byte[file.ContentLength];
                int            bytesReaded = file.InputStream.Read(buffer, 0, FileUpload1.PostedFile.ContentLength);
                //the HttpPostedFile has InputStream porperty (using System.IO;)
                //which can read the stream to the buffer object,
                //the first parameter is the array of bytes to store in,
                //the second parameter is the zero index (of specific byte) where to start storing in the buffer,
                //the third parameter is the number of bytes you want to read (do u care about this?)
                if (bytesReaded > 0)
                {
                    try
                    {
                        var upload = new Upload()
                        {
                            name          = FileUpload1.FileName,
                            content_type  = FileUpload1.PostedFile.ContentType,
                            created_at    = DateTime.Now,
                            data          = buffer,
                            modified_at   = DateTime.Now,
                            user_id       = (int)id,
                            file_location = file.ContentLength.ToString()
                        };

                        _insendluEntities.Uploads.Add(upload);

                        var i = _insendluEntities.SaveChanges();

                        var filename = Page.Server.MapPath("~/Uploads/Tutorials/" + Path.GetFileName(file.FileName));
                        file.SaveAs(filename);
                    }
                    catch (Exception ex)
                    {
                        //Label1.Text = ex.Message;
                    }
                }
            }
            else
            {
                //Label1.Text = "Choose a valid video file";
            }
        }
Beispiel #12
0
        private void DeleteDocument(object sender, GridViewCommandEventArgs e)
        {
            var rowno = int.Parse(e.CommandArgument.ToString());  // It is the rowno of which the user as clicked

            var row   = datagridview.Rows[rowno];
            var label = (Label)row.FindControl("lblId");
            var id    = Convert.ToInt32(label.Text);

            var upload = (from up in _insendluEntities.ProjectDocuments
                          where up.id == id
                          select up).Single();

            var docName = upload.name;

            Remove(docName);

            _insendluEntities.ProjectDocuments.Remove(upload);
            _insendluEntities.SaveChanges();
        }
Beispiel #13
0
        private void UpdatePassword(string password, string email, string temp)
        {
            var user = _userService.GetUserByEmailAndTempPass(email, temp);

            if (user != null)
            {
                var enCrypt = _encryptor.Encrypt(password);

                user.password           = enCrypt;
                user.status             = 1;
                user.temporary_password = String.Empty;

                _insendluEntities.Entry(user).State = EntityState.Modified;
                int success = _insendluEntities.SaveChanges();

                if (success == 1)
                {
                    Session["passupdated"] = true;
                    Response.Redirect("index.aspx");
                }
            }
        }
Beispiel #14
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 #15
0
        protected void Update_OnClick(object sender, EventArgs e)
        {
            var id           = Convert.ToInt64(Session["ID"]);
            var modification = DateTime.Now;

            var comp         = RemoveHtml(companyBackground.Content);
            var execSumm     = RemoveHtml(execSummary.Content);
            var costP        = RemoveHtml(costPlan.Content);
            var methodol     = RemoveHtml(propMethodology.Content);
            var poli         = RemoveHtml(policyNum.Content);
            var projDesc     = RemoveHtml(descriptionPro.Text);
            var projName     = ProjName.Value;
            var conlusion    = RemoveHtml(conclusion.Content);
            var bee          = RemoveHtml(BBEstatus.Content);
            var coverpage    = RemoveHtml(coverPage.Content);
            var implement    = RemoveHtml(implemantation.Content);
            var jvCompany    = RemoveHtml(jvcompany.Content);
            var scope        = RemoveHtml(projScope.Content);
            var projRef      = RemoveHtml(projReference.Content);
            var team         = RemoveHtml(projTeam.Content);
            var riskAnalysis = RemoveHtml(riskanalysis.Content);
            var whyC         = RemoveHtml(whyChoose.Content);


            var proj = _projectService.GetProjectById(id);

            proj.description  = projDesc;
            proj.name         = projName;
            proj.project_type = type.Value;
            proj.conclusion   = conlusion;
            proj.modified_at  = modification;

            _insendluEntities.Entry(proj).State = System.Data.Entity.EntityState.Modified;
            _insendluEntities.SaveChanges();

            var execSummar = (from exec in _insendluEntities.ExecutiveSummaries
                              where exec.proj_id == id
                              select exec).SingleOrDefault();

            UpdateExecSummary(execSumm, execSummar, modification);

            var cover = (from exec in _insendluEntities.ProjectCoverPages
                         where exec.proj_id == id
                         select exec).SingleOrDefault();

            UpdateCoverpage(coverpage, cover, modification);

            var beeStats = (from exec in _insendluEntities.BEEStatus
                            where exec.proj_id == id
                            select exec).SingleOrDefault();

            UpdateBeeStatus(bee, beeStats, modification);

            var implementation = (from exec in _insendluEntities.ProjectImplementationTimes
                                  where exec.proj_id == id
                                  select exec).SingleOrDefault();

            UpdateImplementation(implement, implementation, modification);

            var jv = (from exec in _insendluEntities.projectJVCompanies
                      where exec.proj_id == id
                      select exec).SingleOrDefault();

            UpdateJVCompany(jvCompany, jv, modification);

            var scopOfwork = (from exec in _insendluEntities.ProjectScopeOfWorks
                              where exec.proj_id == id
                              select exec).SingleOrDefault();

            UpdateScopeOfWork(scope, scopOfwork, modification);


            var reference = (from exec in _insendluEntities.ProjectReferences
                             where exec.proj_id == id
                             select exec).SingleOrDefault();

            UpdateReference(projRef, reference, modification);

            var risk = (from exec in _insendluEntities.RiskAnalysis
                        where exec.proj_id == id
                        select exec).SingleOrDefault();

            UpdateRiskAnalysis(riskAnalysis, risk, modification);

            var proTeam = (from exec in _insendluEntities.ProjectTeams
                           where exec.proj_id == id
                           select exec).SingleOrDefault();

            UpdateProjectTeam(team, proTeam, modification);

            var whyChoze = (from exec in _insendluEntities.WhyChooseBizs
                            where exec.proj_id == id
                            select exec).SingleOrDefault();

            UpdateWhyChoose(whyC, whyChoze, modification);


            var plan = (from cost in _insendluEntities.ProjectCostPlans
                        where cost.proj_id == id
                        select cost).SingleOrDefault();

            UpdateCostPlan(costP, plan, modification);

            var company = (from compan in _insendluEntities.Companies
                           where compan.proj_id == id
                           select compan).SingleOrDefault();

            UpdateCompany(comp, company, modification);

            var methodology = (from meth in _insendluEntities.ProjectMethodologies
                               where meth.proj_id == id
                               select meth).SingleOrDefault();

            UpdateProjectMethodology(methodol, methodology, modification);

            var policy = (from polic in _insendluEntities.ProjectPolicies
                          where polic.proj_id == id
                          select polic).SingleOrDefault();

            UpdateprojectPolicy(poli, policy, modification);


            SaveProject(proj);

            Response.Redirect("~/Proposals.aspx");
        }
        protected void changeProfilePic_OnClick(object sender, EventArgs e)
        {
            var name    = txtName.Value;
            var surname = txtSurname.Value;
            var contact = txtContact.Text;
            var id      = Convert.ToInt64(Session["ID"]);
            var file    = FileUpload.HasFile;

            if (file && (FileUpload.PostedFile.ContentType == "image/jpeg"))
            {
                var byteArray = _imageService.ReadToEnd(FileUpload.PostedFile.InputStream);


                var getProfile = (from prof in _insendluEntities.UserProfiles
                                  where prof.user_id == id
                                  select prof).SingleOrDefault();

                var user = (from prof in _insendluEntities.Users
                            where prof.id == id
                            select prof).SingleOrDefault();
                if (user != null)
                {
                    user.contact_number = contact;

                    _insendluEntities.SaveChanges();
                }

                if (getProfile != null)
                {
                    getProfile.contact_number = contact;
                    getProfile.profile_pic    = byteArray;
                    try
                    {
                        _insendluEntities.SaveChanges();
                    }
                    catch (DbEntityValidationException validation)
                    {
                        var error = validation.EntityValidationErrors;
                    }
                }
                else
                {
                    var profile = new UserProfile
                    {
                        contact_number = contact,
                        profile_pic    = byteArray,
                        user_id        = (int)id
                    };

                    _insendluEntities.UserProfiles.Add(profile);

                    _insendluEntities.SaveChanges();
                }
            }
            else
            {
                var getProfile = (from prof in _insendluEntities.UserProfiles
                                  where prof.user_id == id
                                  select prof).SingleOrDefault();

                var user = (from prof in _insendluEntities.Users
                            where prof.id == id
                            select prof).SingleOrDefault();

                if (user != null)
                {
                    user.contact_number = contact;

                    _insendluEntities.SaveChanges();
                }

                if (getProfile != null)
                {
                    getProfile.contact_number = contact;

                    _insendluEntities.SaveChanges();
                }
                else
                {
                    var profile = new UserProfile
                    {
                        contact_number = contact,
                        user_id        = (int)id
                    };

                    _insendluEntities.UserProfiles.Add(profile);

                    _insendluEntities.SaveChanges();
                }
            }

            ProfilePictureUpdate(id);
            ProfileUpdate(id);
        }
Beispiel #17
0
        protected void saveLoggedInfo_OnClick(object sender, EventArgs e)
        {
            var query     = Request.QueryString;
            var workLogId = Convert.ToInt64(query.Get("id"));
            var date      = Convert.ToDateTime(query.Get("date"));

            var accom = (from acc in _insendluEntities.Accommodations
                         where acc.worklog_id == workLogId
                         select acc).SingleOrDefault();

            if (accom != null)
            {
                accom.cost       = Convert.ToInt32(accCost.Text);
                accom.location   = accLocation.Text;
                accom.start_date = Convert.ToDateTime(Request.Form[start_period.UniqueID]);
                accom.end_start  = Convert.ToDateTime(Request.Form[end_period.UniqueID]);

                _insendluEntities.SaveChanges();
            }

            var vehicle = (from acc in _insendluEntities.Vehicles
                           where acc.worklog_id == workLogId
                           select acc).SingleOrDefault();

            if (vehicle != null)
            {
                vehicle.cost       = Convert.ToInt32(vCost.Text);
                vehicle.start_date = Convert.ToDateTime(Request.Form[vStartDate.UniqueID]);
                vehicle.end_start  = Convert.ToDateTime(Request.Form[vEndDate.UniqueID]);
                vehicle.mileage    = vMilage.Text;
                vehicle.type       = vType.Text;

                _insendluEntities.SaveChanges();
            }
            var refreshments = (from acc in _insendluEntities.Refreshments
                                where acc.worklog_id == workLogId
                                select acc).SingleOrDefault();

            if (refreshments != null)
            {
                refreshments.cost       = Convert.ToInt32(refCost.Text);
                refreshments.start_date = Convert.ToDateTime(Request.Form[refStartDate.UniqueID]);
                refreshments.end_start  = Convert.ToDateTime(Request.Form[refEndDate.UniqueID]);

                _insendluEntities.SaveChanges();
            }

            var employees = (from acc in _insendluEntities.Employees
                             where acc.worklog_id == workLogId
                             select acc).SingleOrDefault();

            if (employees != null)
            {
                employees.cost            = Convert.ToInt32(empCostPerDay.Text);
                employees.end_start       = Convert.ToDateTime(Request.Form[empEndDate.UniqueID]);
                employees.no_of_employees = empNumber.Text;
                employees.start_date      = Convert.ToDateTime(Request.Form[empStart.UniqueID]);
                employees.employee_type   = empType.Text;

                _insendluEntities.SaveChanges();
            }

            var printMaterial = (from acc in _insendluEntities.PrintMaterials
                                 where acc.worklog_id == workLogId
                                 select acc).SingleOrDefault();

            if (printMaterial != null)
            {
                printMaterial.cost       = Convert.ToInt32(matCost.Text);
                printMaterial.end_start  = Convert.ToDateTime(Request.Form[matEndDate.UniqueID]);
                printMaterial.start_date = Convert.ToDateTime(Request.Form[matStartDate.UniqueID]);
                printMaterial.quantity   = matQuantity.Text;
                printMaterial.name       = materialName.Text;

                _insendluEntities.SaveChanges();
            }

            var telephone = (from acc in _insendluEntities.Telephones
                             where acc.worklog_id == workLogId
                             select acc).SingleOrDefault();

            if (telephone != null)
            {
                telephone.cost       = Convert.ToInt32(telCost.Text);
                telephone.end_start  = Convert.ToDateTime(Request.Form[telEndDate.UniqueID]);
                telephone.start_date = Convert.ToDateTime(Request.Form[telStartDate.UniqueID]);

                _insendluEntities.SaveChanges();
            }

            var wifi = (from acc in _insendluEntities.Wifis
                        where acc.worklog_id == workLogId
                        select acc).SingleOrDefault();

            if (wifi != null)
            {
                wifi.cost       = Convert.ToInt32(wifiCost.Text);
                wifi.end_start  = Convert.ToDateTime(Request.Form[wifiEndDate.UniqueID]);
                wifi.start_date = Convert.ToDateTime(Request.Form[wifiStartDate.UniqueID]);

                _insendluEntities.SaveChanges();
            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Work log updated successfully')", true);
            Response.Redirect("Report.aspx");
        }
Beispiel #18
0
        protected void SubmitButton_OnClick(object sender, EventArgs e)
        {
            var createdDate = DateTime.Now;
            var modifiedAt  = DateTime.Now;
            var conclution  = conclusion.Content;

            var newProj = new Project
            {
                created_at  = createdDate,
                modified_at = modifiedAt,
                description = descriptionPro.Text,
                name        = ProjName.Value,
                status      = EntityStatus.Active.GetHashCode(),
                conclusion  = conclution
            };

            _insendluEntities.Projects.Add(newProj);
            var projId = _insendluEntities.SaveChanges();

            if (projId == 1)
            {
                var newId = newProj.id;

                var executiveSummary = execSummary.Content;
                var id = Executive(executiveSummary, newId);

                var company   = companyBackground.Content;
                var companyId = GetCompany(company, newId);

                //var dpwProperty = dpw.Content;
                //var methId = GetDpw(dpwProperty, newId);

                var methodology = propMethodology.Content;
                var methodoId   = GetMethodology(methodology, newId);


                var costPlanV  = costPlan.Content;
                var costPlanId = GetProjectCostPlan(costPlanV, newId);

                //var bee = whyChoose.Content;
                //var companyId = GetCompanyDetails(bee, newId);

                var projAnalysis = riskanalysis.Content;
                var analysisId   = GetProjectAnalysis(projAnalysis, newId);

                var resources = resource.Content;

                var updateProject = (from pr in _insendluEntities.Projects
                                     where pr.id == newId
                                     select pr).Single();

                if (updateProject != null)
                {
                    updateProject.cost_plan_id    = costPlanId;
                    updateProject.company_id      = companyId;
                    updateProject.exec_summary_id = id;
                    updateProject.methodology_id  = methodoId;
                    updateProject.policy_id       = analysisId;

                    _insendluEntities.SaveChangesAsync();

                    SaveProject(updateProject);
                }
            }
        }
        protected void btnUpdate_OnClick(object sender, EventArgs e)
        {
            var userPosition      = !string.IsNullOrEmpty(txtPosition.Text) ? txtPosition.Text : string.Empty;
            var biographicalInfo  = !string.IsNullOrEmpty(biography.Text) ? biography.Text : string.Empty;
            var motivationaLetter = !string.IsNullOrEmpty(motivation.Text) ? motivation.Text : string.Empty;
            var contact           = !string.IsNullOrEmpty(cellphone.Text) ? cellphone.Text : string.Empty;
            var quali             = !string.IsNullOrEmpty(qualification.Text) ? qualification.Text : string.Empty;
            var depart            = !string.IsNullOrEmpty(department.Text) ? department.Text : string.Empty;
            var responsiblty      = !string.IsNullOrEmpty(responsibility.Text) ? responsibility.Text : string.Empty;
            var award             = !string.IsNullOrEmpty(awards.Text) ? awards.Text : string.Empty;
            var personalIntrst    = !string.IsNullOrEmpty(personalInterest.Text) ? personalInterest.Text : string.Empty;

            var file       = FileUpload.HasFile;
            var getProfile = (from prof in _insendluEntities.UserProfiles where prof.user_id == _id select prof).SingleOrDefault();
            var user       = (from prof in _insendluEntities.Users where prof.id == _id select prof).SingleOrDefault();

            var byteArray = new byte[] { };

            if (file && (FileUpload.PostedFile.ContentType == "image/jpeg"))
            {
                byteArray = _imageService.ReadToEnd(FileUpload.PostedFile.InputStream);
            }

            if (user != null)
            {
                user.contact_number = contact;

                _insendluEntities.SaveChanges();
            }

            if (getProfile != null)
            {
                getProfile.contact_number  = contact;
                getProfile.profile_pic     = byteArray != new byte[] {} ? byteArray : null;
                getProfile.position        = userPosition;
                getProfile.past_experience = biographicalInfo;
                getProfile.biography       = motivationaLetter;

                getProfile.awards            = award;
                getProfile.department        = depart;
                getProfile.personal_interest = personalIntrst;
                getProfile.responsibility    = responsiblty;
                getProfile.qualification     = quali;


                try
                {
                    _insendluEntities.SaveChanges();
                    FillDetails(_id);
                    if (getProfile.profile_pic != null)
                    {
                        SetImage(byteArray);
                    }
                    Response.Redirect("Dashboard.aspx");
                }
                catch (DbEntityValidationException validation)
                {
                    var error = validation.EntityValidationErrors;
                }
            }
            else
            {
                var userProfile = new UserProfile
                {
                    user_id         = _id,
                    position        = userPosition,
                    past_experience = biographicalInfo,
                    biography       = motivationaLetter,
                    contact_number  = contact,
                    profile_pic     = byteArray != new byte[] { } ? byteArray : null,
                    awards            = award,
                    department        = depart,
                    personal_interest = personalIntrst,
                    qualification     = quali,
                    responsibility    = responsiblty
                };

                _insendluEntities.UserProfiles.Add(userProfile);
                _insendluEntities.SaveChanges();

                if (userProfile.profile_pic != null)
                {
                    SetImage(byteArray);
                }

                FillDetails(_id);
                Response.Redirect("Dashboard.aspx");
            }
        }
        protected void SubmitButton_OnClick(object sender, EventArgs e)
        {
            var createdDate = DateTime.Now;
            var modifiedAt  = DateTime.Now;
            var projecType  = typeEnvelop.SelectedIndex;
            //var type = _projectService.GetTypeById(projecType);
            var completed  = Convert.ToInt32(isComplete.Value) == 1 ? true : false;
            var conclution = RemoveHtml(conclusion.Content);
            var cName      = clientName.Text;

            var selectedCvs      = lstBoxCV.Items;
            var selectReferences = refList.Items;
            var cvList           = new List <string>();
            var referenceList    = new List <string>();

            foreach (var cv in selectedCvs)
            {
                var cvItem = cv as ListItem;
                cvList.Add(cvItem.Text.Split(',')[0]);
            }
            foreach (var reference in selectReferences)
            {
                var referenceItem = reference as ListItem;
                referenceList.Add(referenceItem.Text.Split(',')[0]);
            }
            var client = new Client
            {
                name        = cName,
                created_at  = DateTime.Now,
                modified_at = DateTime.Now,
                status      = (int)EntityStatus.Active
            };

            _insendluEntities.Clients.Add(client);
            _insendluEntities.SaveChanges();

            var newProj = new Project
            {
                created_at   = createdDate,
                modified_at  = modifiedAt,
                description  = descriptionPro.Text,
                name         = ProjName.Value,
                status       = ProjectStatus.Active.GetHashCode(),
                conclusion   = conclution,
                user_id      = Convert.ToInt32(Session["ID"]),
                sector_id    = drpSector.SelectedIndex,
                project_type = type.SelectedValue,
                proj_envelop = projecType,
                client_id    = client.id,
                is_completed = completed
            };

            _insendluEntities.Projects.Add(newProj);
            var projId = _insendluEntities.SaveChanges();

            if (projId == 1)
            {
                var newId = newProj.id;

                // Project CV and REFERENCES
                var projCvReference = new ProjectCvsAndReference
                {
                    created_at  = DateTime.Now,
                    modified_at = DateTime.Now,
                    cvs         = string.Join(",", cvList),
                    references  = string.Join(",", referenceList),
                    project_id  = (int)newId
                };

                _insendluEntities.ProjectCvsAndReferences.Add(projCvReference);
                _insendluEntities.SaveChanges();

                var allowedDocTypes = new string[] { ".doc", ".docx", ".png", ".jpeg", ".jpg" };
                //Project Cost Document(s)
                foreach (var file in fileUpload.PostedFiles)
                {
                    if (allowedDocTypes.Contains(file.ContentType))
                    {
                        var fileName = Page.Server.MapPath("~/Uploads/ProjectDocs/ProjectCosts/" + newId + "," + Path.GetFileName(file.FileName));
                        file.SaveAs(fileName);
                    }
                }

                //exec
                var executiveSummary = RemoveSpecialCharacters(RemoveHtml(execSummary.Content));
                var id = Executive(executiveSummary, newId);

                //company
                var missionState    = missionStatement.Text;
                var serviceOfer     = serviceOffering.Items;
                var backgroundCheck = backgroundStatement.Text;

                var selectedServices = new List <string>(serviceOfer.Count);

                foreach (var service in serviceOfer)
                {
                    var serve = (ListItem)service;

                    if (serve.Selected)
                    {
                        selectedServices.Add(serve.Value);
                    }
                }

                UpdateCompanyBackground(missionState, backgroundCheck, selectedServices);

                //coverpage
                var prepared       = preparedFor.Text;
                var reasonProposal = reasonForProposal.Text;

                var coverId = GetCoverpage(prepared, reasonProposal, newId);

                //methodology
                var methodology = RemoveSpecialCharacters(RemoveHtml(propMethodology.Content));
                var methodoId   = GetMethodology(methodology, newId);

                //cost plan
                //var costPlanV = RemoveHtml(costPlan.Content);
                //var costPlanId = GetProjectCostPlan(costPlanV, newId);

                //BBBEE
                var bee    = RemoveSpecialCharacters(RemoveHtml(whyChoose.Content));
                var bbeeId = GetBBEE(bee, newId);

                //analysis
                var projAnalysis = RemoveSpecialCharacters(RemoveHtml(riskanalysis.Content));
                var analysisId   = GetProjectAnalysis(projAnalysis, newId);

                //scope of work
                var scopeId = GetProjectScope(projScopeAim.Text, purpose.Text, deliverables.Text, newId);

                //jv company
                //var jv = RemoveHtml(jvcompany.Content);
                //var jvId = GetJVCompany(jv, newId);

                //team
                var team   = RemoveSpecialCharacters(RemoveHtml(projTeam.Content));
                var teamId = GetProjectTeam(team, newId);

                //implementation
                var implement = RemoveSpecialCharacters(RemoveHtml(implemantation.Content));
                var implId    = GetProjectImplementation(implement, newId);

                //reference
                //var reference = RemoveHtml(projReference.Content);
                //var refId = GetProjectReference(reference, newId);

                //why choose
                var why   = RemoveSpecialCharacters(RemoveHtml(whyChoose.Content));
                var whyId = GetProjectWhyChoose(why, newId);

                //policy
                //var policy = RemoveHtml(policyNum.Content);
                //var policyId = GetProjectPolicy(policy, newId);


                var updateProject = (from pr in _insendluEntities.Projects
                                     where pr.id == newId
                                     select pr).Single();

                if (updateProject != null)
                {
                    //updateProject.cost_plan_id = costPlanId;
                    updateProject.exec_summary_id = id;
                    updateProject.methodology_id  = methodoId;
                    updateProject.risk_id         = analysisId;
                    //updateProject.policy_id = policyId;
                    updateProject.coverpage_id = coverId;
                    updateProject.bee_id       = bbeeId;
                    updateProject.scope_id     = scopeId;
                    //updateProject.jvCompany_id = jvId;
                    updateProject.projectTeam_id = teamId;
                    updateProject.implement_id   = implId;
                    // updateProject.proj_reference = refId;
                    updateProject.whyChoose_id = whyId;

                    int x = _insendluEntities.SaveChanges();

                    if (x == 1)
                    {
                        SaveProject(updateProject);

                        if (completed)
                        {
                            Response.Redirect("SupportingDocs.aspx?id=" + newId);
                        }
                        else
                        {
                            Response.Redirect("Proposals.aspx");
                        }
                    }
                }
            }
        }
Beispiel #21
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");
        }
Beispiel #22
0
        protected void work_OnClick(object sender, EventArgs e)
        {
            var query  = Request.QueryString;
            var projId = Convert.ToInt64(query.Get("id"));
            var id     = Convert.ToInt64(Session["ID"]);
            var logId  = 0;
            var test   = Request.Form[cal.UniqueID];
            var date   = new DateTime();
            var chek   = false;

            if (!string.IsNullOrEmpty(test))
            {
                date = Convert.ToDateTime(test).Date;
                chek = CheckWorkLog(projId, date);
            }

            if (string.IsNullOrEmpty(test) || chek)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Error, date cannot be empty or there's already a log for the specified date.')",
                                                            true);

                if (chek)
                {
                    lblError.Text = string.Format("Error, date cannot be empty or there's already a log for the specified date. <b/><a href='http://localhost:62379/ViewLogs.aspx?id={0}'>Click here to view / edit</a>", _logId);
                }
                else
                {
                    lblError.Text = string.Format("Error, date cannot be empty or there's already a log for the specified date.");
                }
            }
            else
            {
                var employ   = employees.Checked;
                var accom    = accomodation.Checked;
                var vehcle   = vehicle.Checked;
                var wifiData = wifi.Checked;
                var refresh  = refreshment.Checked;
                var tel      = telephone.Checked;
                var printing = printMaterial.Checked;

                var log = new WorkLog
                {
                    date_logged = date,
                    proj_id     = (int)projId,
                    user_id     = (int)id
                };

                var check = _projectService.SaveWorkLog(log);

                if (check == 1)
                {
                    logId = (int)log.id;

                    if (employ)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 1,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (vehcle)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 2,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (accom)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 3,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (printing)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 4,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (refresh)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 5,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (tel)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 6,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                    if (wifiData)
                    {
                        var activity = new Activity
                        {
                            asset_id   = 7,
                            worklog_id = logId
                        };

                        _insendluEntities.Activities.Add(activity);

                        _insendluEntities.SaveChanges();
                    }
                }

                Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Work logged successfully for the day')", true);
                Response.Redirect("LogInfo.aspx?id=" + logId);
                lblError.Text = String.Empty;
            }

            employees.Checked     = false;
            accomodation.Checked  = false;
            vehicle.Checked       = false;
            wifi.Checked          = false;
            refreshment.Checked   = false;
            telephone.Checked     = false;
            printMaterial.Checked = false;
        }
Beispiel #23
0
        protected void SubmitButton_OnClick(object sender, EventArgs e)
        {
            var createdDate = DateTime.Now;
            var modifiedAt  = DateTime.Now;
            //var projecType = Convert.ToInt32(type);
            //var type = _projectService.GetTypeById(projecType);
            var conclution = RemoveHtml(conclusion.Content);

            var newProj = new Project
            {
                created_at      = createdDate,
                modified_at     = modifiedAt,
                description     = descriptionPro.Text,
                name            = ProjName.Value,
                status          = ProjectStatus.Pending.GetHashCode(),
                conclusion      = conclution,
                user_id         = Convert.ToInt32(Session["ID"]),
                department_name = txtDepartment.Text,
                project_type    = type.Value
            };

            _insendluEntities.Projects.Add(newProj);
            var projId = _insendluEntities.SaveChanges();

            if (projId == 1)
            {
                var newId = newProj.id;

                //exec
                var executiveSummary = RemoveHtml(execSummary.Content);
                var id = Executive(executiveSummary, newId);

                //company jv
                var company   = RemoveHtml(companyBackground.Content);
                var companyId = GetCompany(company, newId);

                //coverpage
                var coverpage = RemoveHtml(coverPage.Content);
                var coverId   = GetCoverpage(coverpage, newId);

                //methodology
                var methodology = RemoveHtml(propMethodology.Content);
                var methodoId   = GetMethodology(methodology, newId);

                //cost plan
                var costPlanV  = RemoveHtml(costPlan.Content);
                var costPlanId = GetProjectCostPlan(costPlanV, newId);

                //BBBEE
                var bee    = RemoveHtml(whyChoose.Content);
                var bbeeId = GetBBEE(bee, newId);

                //analysis
                var projAnalysis = RemoveHtml(riskanalysis.Content);
                var analysisId   = GetProjectAnalysis(projAnalysis, newId);

                //scope of work
                var scope   = RemoveHtml(projScope.Content);
                var scopeId = GetProjectScope(scope, newId);

                //jv company
                var jv   = RemoveHtml(jvcompany.Content);
                var jvId = GetJVCompany(jv, newId);

                //team
                var team   = RemoveHtml(projTeam.Content);
                var teamId = GetProjectTeam(team, newId);

                //implementation
                var implement = RemoveHtml(implemantation.Content);
                var implId    = GetProjectImplementation(implement, newId);

                //reference
                var reference = RemoveHtml(projReference.Content);
                var refId     = GetProjectReference(reference, newId);

                //why choose
                var why   = RemoveHtml(whyChoose.Content);
                var whyId = GetProjectWhyChoose(why, newId);

                //policy
                var policy   = RemoveHtml(policyNum.Content);
                var policyId = GetProjectPolicy(policy, newId);


                var updateProject = (from pr in _insendluEntities.Projects
                                     where pr.id == newId
                                     select pr).Single();

                if (updateProject != null)
                {
                    updateProject.cost_plan_id    = costPlanId;
                    updateProject.company_id      = companyId;
                    updateProject.exec_summary_id = id;
                    updateProject.methodology_id  = methodoId;
                    updateProject.risk_id         = analysisId;
                    updateProject.policy_id       = policyId;
                    updateProject.coverpage_id    = coverId;
                    updateProject.bee_id          = bbeeId;
                    updateProject.scope_id        = scopeId;
                    updateProject.jvCompany_id    = jvId;
                    updateProject.projectTeam_id  = teamId;
                    updateProject.implement_id    = implId;
                    updateProject.proj_reference  = refId;
                    updateProject.whyChoose_id    = whyId;

                    int x = _insendluEntities.SaveChanges();

                    if (x == 1)
                    {
                        var url = string.Format("");
                        Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Proposal saved successfully, to view click here')", true);

                        SaveProject(updateProject);

                        Response.Redirect("SupportingDocs.aspx?id=" + newId);
                    }
                }
            }
        }