Exemple #1
0
        private void AddMaster()
        {
            DVTEntities1       db = new DVTEntities1();
            registerController rc = new registerController();


            DataGridCell c  = dataGridHelper.GetCell(datadrid1, 0, 0);
            DataGridCell bh = dataGridHelper.GetCell(datadrid1, 0, 1); //get rows and column

            ComboBox  cmbNames = (ComboBox)c.Content;                  //get content
            TextBlock txthours = (TextBlock)bh.Content;
            var       hr       = txthours.Text;

            if (!Regex.IsMatch(hr, "^((?:[0-9]|1[0-9]|2[0-3])(?:\\.\\d{1,2})?|24(?:\\.00?)?)$"))
            {
                MessageBox.Show("Invalid input for Hours");
            }

            AttendanceMasterTb master = new AttendanceMasterTb();

            //master.Date = DpDates.SelectedDate;
            //master.MentorPersonId = 7;
            //master.Training = txtTraining.Text;

            var na1 = cmbNames.SelectedItem.ToString();//check the name

            var             mentor = txtMentors.SelectedItem.ToString();
            List <PersonTb> query1 = (from x in db.PersonTbs
                                      where x.Names == mentor
                                      select x).ToList();

            foreach (var item in query1)//loop throur the list to get the person id
            {
                master.Date           = DpDates.SelectedDate;
                master.MentorPersonId = item.PersonId;
                master.Training       = txtTraining.Text;
            }
            rc.insertMaster(master);


            var             na    = cmbNames.SelectedItem.ToString();//check the name
            List <PersonTb> query = (from x in db.PersonTbs
                                     where x.Names == na
                                     select x).ToList();
            //MessageBox.Show(na.ToString());
            AttendanceDetailsTb details = new AttendanceDetailsTb();

            foreach (var item in query)//loop throur the list to get the person id
            {
                details.MasterId        = master.MasterId;
                details.MenteeePersonId = item.PersonId;
                details.Hours           = hr;
            }


            rc.insertDetails(details);
            MessageBox.Show("Saved");
        }
Exemple #2
0
        public string insertMaster(AttendanceMasterTb details)
        {
            try
            {
                DVTEntities1 db = new DVTEntities1();

                db.AttendanceMasterTbs.Add(details);
                db.SaveChanges();
                return("Inserted");
            }
            catch (Exception)
            {
                throw;
            }
        }