Esempio n. 1
0
    public static bool saveProject(string Projectname)
    {
        var        createdate = "10-10-20";
        EmpProject project    = new EmpProject {
            Project_Name = Projectname
        };

        WebClient webClient = new WebClient();

        webClient.Headers[HttpRequestHeader.ContentType] = "application/json";

        DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(EmpProject));
        MemoryStream memStrToSend = new MemoryStream();

        objJsonSerSend.WriteObject(memStrToSend, project);
        string data = Encoding.Default.GetString(memStrToSend.ToArray());

        var res = webClient.UploadString(URL + "/addProject", "POST", data);

        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(res));
        DataContractJsonSerializer recv = new DataContractJsonSerializer(typeof(bool));
        bool httpResponse = (bool)recv.ReadObject(ms);



        return(httpResponse);
    }
        public ActionResult DeleteConfirmed(int id)
        {
            EmpProject empProject = db.EmpProjects.Find(id);

            db.EmpProjects.Remove(empProject);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "EPId,PId,EId,Date")] EmpProject empProject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(empProject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EId = new SelectList(db.Employees, "Eid", "Ename", empProject.EId);
     ViewBag.PId = new SelectList(db.Projects, "PId", "PName", empProject.PId);
     return(View(empProject));
 }
        // GET: EmpProjects/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmpProject empProject = db.EmpProjects.Find(id);

            if (empProject == null)
            {
                return(HttpNotFound());
            }
            return(View(empProject));
        }
Esempio n. 5
0
    protected void btnUpdateProject_Click(object sender, EventArgs e)
    {
        try
        {
            EmpProject project = new EmpProject
            {
                Project_Name    = txtEditProjectName.Text,
                Project_Type    = ddlEditProjectType.SelectedValue.ToString(),
                project_subtype = ddlEditProjectSubType.SelectedValue.ToString(),
                Project_duedate = txtEditDueDate.Text,
                project_manager = ddlEditProjectManager.SelectedValue.ToString(),
                Description     = txtEditDescription.Text,
                Source          = txtEditProjectSource.Text,
                fk_idlogin      = "******"
            };


            DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(EmpProject));
            MemoryStream memStrToSend = new MemoryStream();
            objJsonSerSend.WriteObject(memStrToSend, project);
            string data = Encoding.Default.GetString(memStrToSend.ToArray());

            //string data = JsonConvert.SerializeObject(employee);
            WebClient webClient = new WebClient();
            webClient.Headers[HttpRequestHeader.ContentType] = "application/json";

            var res = webClient.UploadString(URL + "/UpdateProject", "POST", data);

            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(res));
            DataContractJsonSerializer recv = new DataContractJsonSerializer(typeof(bool));
            bool httpResponse = (bool)recv.ReadObject(ms);

            if (httpResponse)
            {
                allClear();
                string add = "Project Update Successfully ! ";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true);
            }
            else
            {
                string error = "Project Update Failed ! ";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "OnError('" + error + "');", true);
            }
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
        // GET: EmpProjects/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmpProject empProject = db.EmpProjects.Find(id);

            if (empProject == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EId = new SelectList(db.Employees, "Eid", "Ename", empProject.EId);
            ViewBag.PId = new SelectList(db.Projects, "PId", "PName", empProject.PId);
            return(View(empProject));
        }
        public IActionResult Index()
        {
            Project p = new Project()
            {
                Pid = "P0001", Pname = "HealthCare"
            };
            Employee e = new Employee()
            {
                Eid = 1, Ename = "Rohan", Pid = "P0001"
            };
            EmpProject ep = new EmpProject()
            {
                Employee = e, Project = p
            };

            return(View(ep));
        }
        public ActionResult Create([Bind(Include = "EPId,PId,EId,Date")] EmpProject empProject)
        {
            if (ModelState.IsValid)
            {
                int pId     = empProject.PId;
                var project = (from db in db.EmpProjects where db.PId == pId select db).FirstOrDefault();
                if (project != null)
                {
                    ViewBag.Message = "Employee has already been assigned a project";
                }
                else
                {
                    db.EmpProjects.Add(empProject);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.EId = new SelectList(db.Employees, "Eid", "Ename", empProject.EId);
            ViewBag.PId = new SelectList(db.Projects, "PId", "PName", empProject.PId);
            return(View(empProject));
        }
Esempio n. 9
0
    protected void btncreate_Click(object sender, EventArgs e) //MARK:- it adds new project
    {
        try
        {
            var      members = listmembers.SelectedValue.ToString();
            string[] membs   = new string[0];
            var      k       = 0;
            for (int i = 0; i < listmembers.Items.Count; i++)
            {
                if (listmembers.Items[i].Selected)
                {
                    Array.Resize(ref membs, membs.Length + 1);
                    membs[k] = listmembers.Items[i].Value;
                    k++;
                }
            }



            EmpProject project = new EmpProject
            {
                Project_Name    = txtProjectName.Text,
                Project_Type    = ddlptype.SelectedValue.ToString(),
                project_subtype = ddlsubtype.SelectedValue.ToString(),
                Project_duedate = txtduedate.Text,
                project_manager = ddlprojectmanager.SelectedValue.ToString(),
                Description     = txtDescription.Text,
                Source          = txtSource.Text,
                TeamID          = membs,
                fk_idlogin      = "******"
            };


            DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(EmpProject));
            MemoryStream memStrToSend = new MemoryStream();
            objJsonSerSend.WriteObject(memStrToSend, project);
            string data = Encoding.Default.GetString(memStrToSend.ToArray());

            //string data = JsonConvert.SerializeObject(employee);
            WebClient webClient = new WebClient();
            webClient.Headers[HttpRequestHeader.ContentType] = "application/json";

            var res = webClient.UploadString(URL + "/addProject", "POST", data);

            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(res));
            DataContractJsonSerializer recv = new DataContractJsonSerializer(typeof(bool));
            bool httpResponse = (bool)recv.ReadObject(ms);

            if (httpResponse)
            {
                allClear();
                listmembers.ClearSelection();
                GetActiveAndSuspendProjectCount();
                string add = "Project Create Successfully ! ";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true);
            }
            else
            {
                string add = "Project Create Failed ! ";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "OnError('" + add + "');", true);
            }
        }
        catch (Exception ex)
        {
            Log.Write("Exception In Add Project " + ex.ToString(), "");
        }
    }