示例#1
0
        // // // // // //


        //Uplaoding the File into Database
        // // // // // //
        private void uploadButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (var context = new DemoBoxDBContext())
                {
                    FileStream   fs       = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
                    BinaryReader rdr      = new BinaryReader(fs);
                    byte[]       fileData = rdr.ReadBytes((int)fs.Length);
                    rdr.Close();
                    fs.Close();

                    file = new DemoBoxThrid.File();

                    file.FileName      = fi.FullName;
                    file.Data          = fileData;
                    file.FileExtension = fi.Extension;
                    file.ProjectId     = proId;
                    file.EmployeeId    = id;

                    context.Files.Add(file);
                    context.SaveChanges();
                }
            }
            catch
            {
            }
        }
示例#2
0
        // // // // // //


        //Setting EmployeeId,EmployeeName,EmployeeRole, at the top of Form in empNameLabel
        // // // // // //
        private void EmployeeManagement_Load(object sender, EventArgs e)
        {
            try
            {
                using (var context = new DemoBoxDBContext())
                {
                    //Setting Employee Name According to Login
                    var query = from x in context.Employees
                                where x.EmployeeEmail == email
                                select x.EmployeeName;
                    foreach (var em in query)
                    {
                        empNameLabel.Text = em;
                    }

                    //Seting Employee ID According to Login
                    var query1 = from x in context.Employees
                                 where x.EmployeeEmail == email
                                 select x.EmployeeId;

                    foreach (var em in query1)
                    {
                        this.id = em;
                        employeeIdLabel.Text = "" + em;
                    }

                    //

                    //Seting Employee Status Accoding to Login
                    var query2 = from x in context.Employees
                                 where x.EmployeeEmail == email
                                 select x.EmployeeStatus;

                    foreach (var em in query2)
                    {
                        if (em != null)
                        {
                            empStatusTextLabel.Text = "" + em;
                        }
                        else
                        {
                            empStatusTextLabel.Text = "Nill";
                        }
                    }

                    //Setting Employee Status According to Login
                    var query3 = from x in context.Employees
                                 where x.EmployeeRole == role
                                 select x.EmployeeRole;
                    foreach (var em in query3)
                    {
                        if (em == 2)
                        {
                            joinedAsTextLabel.Text = "Team Leader";
                        }
                        else if (em == 3)
                        {
                            joinedAsTextLabel.Text = "Analyst";
                        }
                        else if (em == 4)
                        {
                            joinedAsTextLabel.Text = "Designer";
                        }

                        else if (em == 5)
                        {
                            joinedAsTextLabel.Text = "Programmer";
                        }

                        else if (em == 6)
                        {
                            joinedAsTextLabel.Text = "Tester";
                        }
                    }

                    //Setting ProjectId
                    var query4 = from x in context.ProjectEmployees
                                 where x.EmployeeId == id
                                 select x.ProjectId;

                    foreach (var em in query4)
                    {
                        this.proId = em;
                    }

                    //Loading Project on List View
                    string name, file;
                    var    query5 = from p in context.Projects
                                    join c in context.Files on p.ProjectId equals c.ProjectId
                                    select new { projectName = p.ProjectName, c.FileName };

                    foreach (var em in query5)
                    {
                        name = em.projectName;
                        file = em.FileName;

                        ListViewItem lvi1 = new ListViewItem();
                        lvi1.Text = name;
                        lvi1.SubItems.Add(file);

                        projectOnWorkListView.Items.Add(lvi1);
                    }
                }
            }
            catch
            {
            }
        }