Exemple #1
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());
                }
            }
        }
Exemple #2
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());
                    }
                }
            }
        }