예제 #1
0
        DataTable DT(List <EmergencyMaintenance> assets)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Asset SN");
            table.Columns.Add("Asset Name");
            table.Columns.Add("Request Date");
            table.Columns.Add("Employee Full Name");
            table.Columns.Add("Department");
            table.Columns.Add("ID1");
            table.Columns.Add("ID2");

            foreach (var item in assets)
            {
                using (Session2Entities db = new Session2Entities())
                {
                    if (item.EMEndDate == null)
                    {
                        DataRow dataRow = table.NewRow();
                        dataRow["Asset SN"]           = item.Asset.AssetSN;
                        dataRow["Asset Name"]         = item.Asset.AssetName;
                        dataRow["Request Date"]       = item.EMReportDate;
                        dataRow["Employee Full Name"] = item.Asset.Employee.FirstName + " " + item.Asset.Employee.LastName;
                        dataRow["Department"]         = item.Asset.DepartmentLocation.Department.Name;
                        dataRow["ID1"] = item.AssetID;
                        dataRow["ID2"] = item.ID;
                        table.Rows.Add(dataRow);
                    }
                }
            }
            return(table);
        }
예제 #2
0
        private void SubmitBtn_Click(object sender, EventArgs e)
        {
            using (Session2Entities db = new Session2Entities())
            {
                if (partsList != null)
                {
                    foreach (var item in partsList)
                    {
                        db.ChangedParts.Add(item);
                    }
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }

                EmergencyMaintenance em = db.EmergencyMaintenances.Where(x => x.ID == IDss).FirstOrDefault();
                em.EMStartDate      = StartDate.Value;
                em.EMEndDate        = EndDate.Value;
                em.EMTechnicianNote = NoteTxt.Text.Trim();
                try
                {
                    db.SaveChanges();
                    this.Hide();
                }
                catch (Exception es)
                {
                    MessageBox.Show(es.ToString());
                }
            }
        }
예제 #3
0
 private void OkBtn_Click(object sender, EventArgs e)
 {
     using (Session2Entities db = new Session2Entities())
     {
         var username = usernameTxt.Text.Trim();
         var password = PasswordTxt.Text.Trim();
         var query    = db.Employees.Where(x => x.Username == username && x.Password == password).FirstOrDefault();
         if (query != null)
         {
             if (query.isAdmin == true)
             {
                 EMManagement management = new EMManagement();
                 this.Hide();
                 management.ShowDialog();
             }
             else
             {
                 AccountableParty accountable = new AccountableParty();
                 this.Hide();
                 accountable.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("Invalid User!");
         }
     }
 }
예제 #4
0
 private void EMManagement_Load(object sender, EventArgs e)
 {
     using (Session2Entities db = new Session2Entities())
     {
         var query = db.EmergencyMaintenances.OrderByDescending(x => x.PriorityID).OrderByDescending(x => x.EMReportDate).ToList();
         dataGridView1.DataSource             = DT(query);
         dataGridView1.SelectionMode          = DataGridViewSelectionMode.FullRowSelect;
         dataGridView1.Columns["ID1"].Visible = false;
     }
 }
예제 #5
0
 private void AddtoListBtn_Click(object sender, EventArgs e)
 {
     using (Session2Entities db = new Session2Entities())
     {
         ChangedPart part = new ChangedPart();
         part.Amount = amt.Value;
         var name  = PartBox.Text.ToString();
         var query = db.Parts.Where(x => x.Name == name).FirstOrDefault();
         part.PartID = query.ID;
         part.EmergencyMaintenanceID = IDss;
         partsList.Add(part);
         dataGridView1.DataSource    = DT(partsList);
         dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     }
 }
예제 #6
0
        private void EMRequest_Load(object sender, EventArgs e)
        {
            using (Session2Entities db = new Session2Entities())
            {
                var query = db.Assets.Where(x => x.ID == IDs).FirstOrDefault();
                AssetSNTxt.Text   = query.AssetSN;
                AssetNameTxt.Text = query.AssetName;
                DeptTxt.Text      = query.DepartmentLocation.Department.Name;

                var query2 = db.Priorities.ToList();
                foreach (var item in query2)
                {
                    comboBox1.Items.Add(item.Name);
                }
                comboBox1.SelectedIndex = 0;
            }
        }
예제 #7
0
 private void EMRequestDetails_Load(object sender, EventArgs e)
 {
     using (Session2Entities db = new Session2Entities())
     {
         var query = db.Assets.Where(x => x.ID == IDs).FirstOrDefault();
         AssetSNTxt.Text   = query.AssetSN;
         AssetNameTxt.Text = query.AssetName;
         DeptTxt.Text      = query.DepartmentLocation.Department.Name;
         StartDate.Value   = DateTime.Now;
         var query2 = db.Parts.ToList();
         foreach (var item in query2)
         {
             PartBox.Items.Add(item.Name);
         }
         //var query3 = db.ChangedParts.Where(x => x.EmergencyMaintenanceID == IDss).ToList();
         dataGridView1.DataSource    = DT(partsList);
         dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     }
 }
예제 #8
0
        DataTable DT(List <Asset> assets)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Asset SN");
            table.Columns.Add("Asset Name");
            table.Columns.Add("Last Closed EM");
            table.Columns.Add("Number of EMs");
            table.Columns.Add("ID");

            foreach (var item in assets)
            {
                using (Session2Entities db = new Session2Entities())
                {
                    DataRow dataRow = table.NewRow();
                    dataRow["Asset SN"]   = item.AssetSN;
                    dataRow["Asset Name"] = item.AssetName;
                    var query  = db.EmergencyMaintenances.Where(x => x.AssetID == item.ID);
                    var query2 = query.OrderByDescending(x => x.EMEndDate).FirstOrDefault();
                    if (query2 != null)
                    {
                        if (query2.EMEndDate == null)
                        {
                            dataRow["Last Closed EM"] = "--";
                        }
                        else
                        {
                            dataRow["Last Closed EM"] = query2.EMEndDate;
                        }
                    }
                    else
                    {
                        dataRow["Last Closed EM"] = "Nil";
                    }

                    dataRow["Number of EMs"] = query.Count();
                    dataRow["ID"]            = item.ID;
                    table.Rows.Add(dataRow);
                }
            }

            return(table);
        }
예제 #9
0
        DataTable DT(List <ChangedPart> parts)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Part Name");
            dt.Columns.Add("Amount");
            foreach (var item in parts)
            {
                using (Session2Entities db = new Session2Entities())
                {
                    DataRow dr    = dt.NewRow();
                    var     id    = item.PartID;
                    var     query = db.Parts.Where(x => x.ID == id).First();
                    dr["Part Name"] = query.Name;
                    dr["Amount"]    = item.Amount;
                    dt.Rows.Add(dr);
                }
            }
            return(dt);
        }
예제 #10
0
 private void AccountableParty_Load(object sender, EventArgs e)
 {
     using (Session2Entities db = new Session2Entities())
     {
         var query = db.Assets.ToList();
         dataGridView1.DataSource            = DT(query);
         dataGridView1.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
         dataGridView1.Columns["ID"].Visible = false;
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             if (row.Cells[2].Value != null)
             {
                 if (row.Cells[2].Value.ToString() == "--")
                 {
                     row.DefaultCellStyle.BackColor = Color.Red;
                 }
             }
         }
     }
 }
예제 #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (Session2Entities db = new Session2Entities())
            {
                var desc   = DescTxt.Text.Trim();
                var others = OtherTxt.Text.Trim();
                var date   = DateTime.Now;

                EmergencyMaintenance maintenance = new EmergencyMaintenance();
                maintenance.AssetID = IDs;
                var query = db.Priorities.Where(x => x.Name == comboBox1.Text).FirstOrDefault();
                maintenance.PriorityID = query.ID;
                if (desc == "" || others == "")
                {
                    MessageBox.Show("Invalid Description or Other Considerations!");
                }
                else
                {
                    maintenance.DescriptionEmergency = desc;
                    maintenance.OtherConsiderations  = others;
                    maintenance.EMReportDate         = date;
                    maintenance.EMStartDate          = date;
                    maintenance.EMEndDate            = null;
                    maintenance.EMTechnicianNote     = null;

                    db.EmergencyMaintenances.Add(maintenance);
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Submitted Successfully!");
                        this.Hide();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }
예제 #12
0
 private void SendEMRBtn_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         foreach (DataGridViewRow row in dataGridView1.SelectedRows)
         {
             if (row.Cells["Last Closed EM"].Value.ToString() != "--")
             {
                 EMRequest request = new EMRequest(long.Parse(row.Cells["ID"].Value.ToString()));
                 request.ShowDialog();
                 using (Session2Entities db = new Session2Entities())
                 {
                     var query = db.Assets.ToList();
                     dataGridView1.DataSource            = DT(query);
                     dataGridView1.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
                     dataGridView1.Columns["ID"].Visible = false;
                     foreach (DataGridViewRow rows in dataGridView1.Rows)
                     {
                         if (rows.Cells[2].Value != null)
                         {
                             if (rows.Cells[2].Value.ToString() == "--")
                             {
                                 rows.DefaultCellStyle.BackColor = Color.Red;
                             }
                         }
                     }
                 }
             }
             else
             {
                 MessageBox.Show("There is still an open request associated with this Asset! You cannot make any other requests!");
             }
         }
     }
     else
     {
         MessageBox.Show("Invalid Selection!");
     }
 }
예제 #13
0
 private void ManageReqBtn_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         foreach (DataGridViewRow row in dataGridView1.SelectedRows)
         {
             EMRequestDetails details = new EMRequestDetails(long.Parse(row.Cells["ID1"].Value.ToString()), long.Parse(row.Cells["ID2"].Value.ToString()));
             details.ShowDialog();
             using (Session2Entities db = new Session2Entities())
             {
                 var query = db.EmergencyMaintenances.OrderByDescending(x => x.PriorityID).OrderByDescending(x => x.EMReportDate).ToList();
                 dataGridView1.DataSource             = DT(query);
                 dataGridView1.SelectionMode          = DataGridViewSelectionMode.FullRowSelect;
                 dataGridView1.Columns["ID1"].Visible = false;
                 dataGridView1.Columns["ID2"].Visible = false;
             }
         }
     }
     else
     {
         MessageBox.Show("Invalid Selection!");
     }
 }