private void Button_DONE(object sender, RoutedEventArgs e)
        {
            DataClassesLinqDataContext db = new DataClassesLinqDataContext(DataAccessClassLinq.connectionStringLinq);

            Teacher teach = new Teacher();

            teach.First_Name   = First.Text;
            teach.Last_Name    = Last.Text;
            teach.Full_Name    = First.Text + " " + Last.Text;
            teach.Fathers_Name = Father.Text;
            teach.Mothers_Name = Mother.Text;
            teach.Gender       = Gender.Text;
            teach.Blood_Group  = Blood.Text;

            if (Married.IsChecked == true)
            {
                teach.Marital_Status = "Married";
            }
            else
            {
                teach.Marital_Status = "UnMarried";
            }

            teach.DOB         = DateTime.Now;
            teach.Joined_Date = DateTime.Now;
            teach.Status      = "Active";

            teach.Mobile      = Mobile.Text;
            teach.Designation = Designation.Text;
            teach.Address     = Address.Text;
            teach.Email       = Email.Text;


            var max = db.Teachers.OrderByDescending(i => i.Teacher_ID).FirstOrDefault();

            string id = "";

            foreach (char a in max.Teacher_ID)
            {
                int val = (int)Char.GetNumericValue(a);
                id = (val + 1).ToString();
            }

            teach.Teacher_ID = id;
            //MessageBox.Show(id);
            db.Teachers.InsertOnSubmit(teach);
            db.SubmitChanges(); //eita main mama

            HR hr = new HR();

            hr.Show();
            this.Close();
        }
Example #2
0
        private async void Add_Task_Click(object sender, RoutedEventArgs e)
        {
            DataClassesLinqDataContext db = new DataClassesLinqDataContext(DataAccessClassLinq.connectionStringLinq);

            //getting max id from datebase
            var max = db.Tasks.OrderByDescending(i => i.Task_ID).FirstOrDefault();

            string taskID = "";

            foreach (char a in max.Task_ID)
            {
                int val = (int)Char.GetNumericValue(a);
                taskID = (val + 1).ToString();
            }

            //storing values to task object
            DAL.Task task = new DAL.Task();

            task.Task_ID          = taskID;
            task.TaskType         = task_type.Text;
            task.Task_Description = Task_Description.Text;
            task.Assigned_Date    = DateTime.Now;
            task.Deadline         = DateTime.Parse(deadline.Text);

            //storing valurs to teacker_task object
            DAL.Teacher_Task teacher_task = new DAL.Teacher_Task();

            teacher_task.Task_ID    = taskID;
            teacher_task.Teacher_ID = Login.getID();

            try
            {
                db.Teacher_Tasks.InsertOnSubmit(teacher_task);
                db.Tasks.InsertOnSubmit(task);
                db.SubmitChanges();

                await this.ShowMessageAsync("Information", "Task assignment successful.");

                HR hr = new HR();
                hr.Show();
                this.Close();
            }
            catch
            {
                await this.ShowMessageAsync("Error", "Task assignment error.");
            }
        }
        private async void Button_DELETE(object sender, RoutedEventArgs e)
        {
            DataClassesLinqDataContext db = new DataClassesLinqDataContext(DataAccessClassLinq.connectionStringLinq);

            Teacher deleteTeacher = db.Teachers.FirstOrDefault(ex => ex.Teacher_ID.Equals(ID.Text));

            try
            {
                db.Teachers.DeleteOnSubmit(deleteTeacher);
                db.SubmitChanges();
                await this.ShowMessageAsync("Information", "Successfully Deleted.");
            }
            catch
            {
                await this.ShowMessageAsync("Error", "Delete unsuccessful.");
            }



            HR hr = new HR();

            hr.Show();
            this.Close();
        }