private static List <Lister> GetListersAllByGroupID(int?id) { List <Lister> ls = new List <Lister>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_GetListersAllByGroupID", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@GroupID", id); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { ls.Add(Lister.GetListerByID(rd.GetInt32(0))); } rd.Close(); } catch { ls = new List <Lister>(); } finally { con.Close(); } return(ls); }
private void btnDelLister_Click(object sender, RoutedEventArgs e) { if (dgListers.SelectedIndex != -1) { if (!BaseDataBase.CurrentUser.CanDelete) { MyMessageBox.Show("ليس لديك صلاحيات للحذف"); } else { Lister l = Lister.GetListerByID((int)(dgListers.Items[dgListers.SelectedIndex] as DataRowView)[0]); if (int.Parse(BaseDataBase._Scalar("select dbo.GetGroupCountByListerID(" + l.ListerID + ")")) > 0) { MyMessageBox.Show("لا يمكن حذف المقيّم \nبسبب وجود بيانات تقييم سابقة له ضمن فرق التقييم"); } else if (int.Parse(BaseDataBase._Scalar("select COUNT(ID) from Trained where TrainedType = 2 and TrainedID = " + l.ListerID)) > 0) { MyMessageBox.Show("لا يمكن حذف المقيّم \nبسبب وجود بيانات تدريب سابقة له"); } else if (DBMain.DeleteData(l)) { dgListers.ItemsSource = Lister.GetAllListersTable; MyMessage.DeleteMessage(); } } } }
public ListerControl(int ListerID) { InitializeComponent(); this.DataContext = Lister.GetListerByID(ListerID); btnExecute.Visibility = System.Windows.Visibility.Hidden; btnUpdate.Visibility = System.Windows.Visibility.Visible; }