private void btnDelLister_Click(object sender, RoutedEventArgs e)
 {
     if (dgSupervisor.SelectedIndex != -1)
     {
         if (!BaseDataBase.CurrentUser.CanDelete)
         {
             MyMessageBox.Show("ليس لديك صلاحيات للحذف");
         }
         else
         {
             Supervisor s = Supervisor.GetSupervisorByID((int)(dgSupervisor.Items[dgSupervisor.SelectedIndex] as DataRowView)[0]);
             if (int.Parse(BaseDataBase._Scalar("select dbo.fn_SupervisorOrphansCount(" + s.SupervisorID + ")")) > 0)
             {
                 MyMessageBox.Show("لا يمكن حذف المشرف \nبسبب وجود بيانات إشراف سابقة له");
             }
             else if (int.Parse(BaseDataBase._Scalar("select COUNT(ID) from Trained where TrainedType = 3 and TrainedID = " + s.SupervisorID)) > 0)
             {
                 MyMessageBox.Show("لا يمكن حذف المشرف \nبسبب وجود بيانات تدريب سابقة له");
             }
             else
             {
                 if (s.DeleteSupervisorData())
                 {
                     dgSupervisor.ItemsSource = Supervisor.GetAllSupervisorTable;
                     MyMessage.DeleteMessage();
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public bool UpdateSupervisorData()
        {
            IdentityImage = BaseDataBase.CheckImageFile(IdentityImage, Supervisor.GetSupervisorByID(SupervisorID).IdentityImage);

            return(BaseDataBase._StoredProcedure("sp_UpdateSupervisor"
                                                 , new SqlParameter("@SupervisorID", SupervisorID)
                                                 , new SqlParameter("@FirstName", FirstName)
                                                 , new SqlParameter("@LastName", LastName)
                                                 , new SqlParameter("@BirthPlace", BirthPlace)
                                                 , new SqlParameter("@DOB", DOB)
                                                 , new SqlParameter("@Gender", Gender)
                                                 , new SqlParameter("@Job", Job)
                                                 , new SqlParameter("@Slary", Slary)
                                                 , new SqlParameter("@Phone", Phone)
                                                 , new SqlParameter("@Mobile", Mobile)
                                                 , new SqlParameter("@Email", Email)
                                                 , new SqlParameter("@MaritalStatus", MaritalStatus)
                                                 , new SqlParameter("@ChildCount", ChildCount)
                                                 , new SqlParameter("@IdentityImage", IdentityImage)
                                                 , new SqlParameter("@PlaceAddress", PlaceAddress)
                                                 , new SqlParameter("@ScientificQualifier", ScientificQualifier)
                                                 , new SqlParameter("@Major", Major)
                                                 , new SqlParameter("@IsActivated", IsActivated)
                                                 , new SqlParameter("@NotActivatedReason", NotActivatedReason)
                                                 , new SqlParameter("@Notes", Notes)));
        }
 private void btnUpdateSupervisor_Click(object sender, RoutedEventArgs e)
 {
     if (dgSupervisor.SelectedIndex >= 0)
     {
         SupervisorControl w = new SupervisorControl(Supervisor.GetSupervisorByID((int)(dgSupervisor.Items[dgSupervisor.SelectedIndex] as DataRowView)[0]));
         if (w.ShowDialog() == true)
         {
             dgSupervisor.ItemsSource = Supervisor.GetAllSupervisorTable;
         }
     }
 }