public static bool DeleteData(SpecialFamily x) { x.GetOrders(); foreach (var item in x.Orders) { Order.DeleteData(item); } return(BaseDataBase._StoredProcedure("sp_Delete_SpecialFamily", new SqlParameter("@Id", x.Id))); }
public static bool UpdateData(SpecialFamily x) { return(BaseDataBase._StoredProcedure("sp_Update_SpecialFamily", new SqlParameter("@Id", x.Id), new SqlParameter("@Name", x.Name), new SqlParameter("@PID", x.PID), new SqlParameter("@FatherName", x.FatherName), new SqlParameter("@MotherName", x.MotherName), new SqlParameter("@Gender", x.Gender), new SqlParameter("@DOB", x.DOB), new SqlParameter("@Notes", x.Notes), new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID))); }
public static bool InsertData(SpecialFamily x) { x.Id = BaseDataBase._StoredProcedureReturnable("sp_Add_SpecialFamily", new SqlParameter("@Id", System.Data.SqlDbType.Int), new SqlParameter("@Name", x.Name), new SqlParameter("@PID", x.PID), new SqlParameter("@FatherName", x.FatherName), new SqlParameter("@MotherName", x.MotherName), new SqlParameter("@Gender", x.Gender), new SqlParameter("@DOB", x.DOB), new SqlParameter("@Notes", x.Notes), new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)); return(x.Id.HasValue); }
public static List <SpecialFamily> GetAllSpecialFamily() { List <SpecialFamily> xx = new List <SpecialFamily>(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_Get_All_SpecialFamily", con); com.CommandType = System.Data.CommandType.StoredProcedure; try { con.Open(); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { SpecialFamily x = new SpecialFamily(); if (!(rd["Id"] is DBNull)) { x.Id = int.Parse(rd["Id"].ToString()); } x.Name = rd["Name"].ToString(); x.PID = rd["PID"].ToString(); x.FatherName = rd["FatherName"].ToString(); x.MotherName = rd["MotherName"].ToString(); x.Gender = rd["Gender"].ToString(); if (!(rd["DOB"] is DBNull)) { x.DOB = DateTime.Parse(rd["DOB"].ToString()); } x.Notes = rd["Notes"].ToString(); if (!(rd["LastUserID"] is DBNull)) { x.LastUserID = int.Parse(rd["LastUserID"].ToString()); } xx.Add(x); } rd.Close(); } catch { xx = null; } finally { con.Close(); } return(xx); }
public static SpecialFamily GetSpecialFamilyByID(int id) { SpecialFamily x = new SpecialFamily(); SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString); SqlCommand com = new SqlCommand("sp_Get_ID_SpecialFamily", con); com.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter pr = new SqlParameter("@ID", id); com.Parameters.Add(pr); try { con.Open(); SqlDataReader rd = com.ExecuteReader(); if (rd.Read()) { if (!(rd["Id"] is DBNull)) { x.Id = int.Parse(rd["Id"].ToString()); } x.Name = rd["Name"].ToString(); x.PID = rd["PID"].ToString(); x.FatherName = rd["FatherName"].ToString(); x.MotherName = rd["MotherName"].ToString(); x.Gender = rd["Gender"].ToString(); if (!(rd["DOB"] is DBNull)) { x.DOB = DateTime.Parse(rd["DOB"].ToString()); } if (!(rd["LastUserID"] is DBNull)) { x.LastUserID = int.Parse(rd["LastUserID"].ToString()); } x.Notes = rd["Notes"].ToString(); } rd.Close(); } catch { x = null; } finally { con.Close(); } return(x); }
private async void btnSearch_Click(object sender, RoutedEventArgs e) { if (!isWorking) { isWorking = true; Storyboard sb = (App.Current.Resources["sbRotateButton"] as Storyboard).Clone(); sb.SetValue(Storyboard.TargetProperty, sender); sb.Begin(); List <SpecialFamily> sfList = null; await Task.Run(() => sfList = SpecialFamily.GetAllSpecialFamily()); sb.Pause(); dg.ItemsSource = sfList; Control_Changed(null, null); isWorking = false; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { var sf = this.DataContext as SpecialFamily; if (sf.IsValidate()) { if (sf.Id.HasValue) { if (SpecialFamily.UpdateData(sf)) { MyMessage.UpdateMessage(); } } else if (SpecialFamily.InsertData(sf)) { MyMessage.InsertMessage(); } } }
private void btnDeleteFamilyData_Click(object sender, RoutedEventArgs e) { if (dg.SelectedItem != null) { var sf = dg.SelectedItem as SpecialFamily; if (BaseDataBase.CurrentUser.IsAdmin) { if (MyMessageBox.Show("هل تريد تأكيد حذف بيانات العائلة الخاصة؟", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (SpecialFamily.DeleteData(sf)) { MyMessage.DeleteMessage(); } } } else { MyMessageBox.Show("لبس لديك صلاحية حذف"); } } }
public SpecialFamilyDetails(SpecialFamily x) { InitializeComponent(); this.DataContext = x; }