private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            var newtf = new TempFamily();
            var oldtf = this.DataContext as TempFamily;

            if (oldtf != null)
            {
                newtf.FamilyType          = oldtf.FamilyType;
                newtf.ApplyDate           = oldtf.ApplyDate;
                newtf.HouseSection        = oldtf.HouseSection;
                newtf.HouseStreet         = oldtf.HouseStreet;
                newtf.HouseOldAddress     = oldtf.HouseOldAddress;
                newtf.HouseBuildingNumber = oldtf.HouseBuildingNumber;
                newtf.HouseFloor          = oldtf.HouseFloor;
                newtf.HouseAddress        = oldtf.HouseAddress;
                newtf.Mobile1             = oldtf.Mobile1;
                newtf.Mobile2             = oldtf.Mobile2;
                newtf.Phone = oldtf.Phone;
            }
            this.DataContext     = null;
            this.DataContext     = newtf;
            grdChild.DataContext = new TempChild();
            //cmboPlace_SelectionChanged(null, null);
            Keyboard.Focus(cmboFamilyType);
        }
        public TempFamilyControl(TempFamily tf)
        {
            InitializeComponent();
            if (tf != null)
            {
                this.DataContext = tf;
            }
            else
            {
                tf               = new TempFamily();
                tf.ApplyDate     = BaseDataBase.DateNow;
                tf.FamilyType    = "نازحين";
                this.DataContext = tf;
            }

            grdChild.DataContext = new TempChild();

            cmboHouseSection.ItemsSource = House.GetHouseSections;
            cmboHouseStreet.ItemsSource  = House.GetHouseStreets;
            cmboOldHouse.ItemsSource     = House.GetOldAddresses;
            if (BaseDataBase.CurrentUser.IsAdmin)
            {
                txtNotes.IsReadOnly = false;
            }
        }
        private void btnExecute_Click(object sender, RoutedEventArgs e)
        {
            MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));

            var tf = this.DataContext as TempFamily;

            if (tf != null)
            {
                if (tf.IsValidate())
                {
                    if (!tf.ID.HasValue)
                    {
                        if (TempFamily.InsertData(tf))
                        {
                            MyMessage.InsertMessage();
                            ColortxtFamilyCode();
                            btnExecute.Content = "تعديل";
                        }
                    }
                    else
                    {
                        if (TempFamily.UpadteData(tf))
                        {
                            MyMessage.UpdateMessage();
                        }
                    }
                }
            }
        }
        private void dgTempFamilys_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (dgTempFamilys.SelectedItem != null)
            {
                e.Handled = true;
                var        id = (int)(dgTempFamilys.SelectedItem as DataRowView)["ID"];
                TempFamily tf = TempFamily.GetTempFamilyByID(id);
                if (tf.IsCancelled)
                {
                    MyMessageBox.Show("لا يمكن تعديل بيانات العائلة لأنه تم إلغاؤها\n\nالسبب : \n" +
                                      tf.CancelReason);
                    return;
                }
                if (!tf.FamilyID.HasValue)
                {
                    if (!BaseDataBase.CurrentUser.CanEnterTempFamily)
                    {
                        MyMessageBox.Show("ليس لديك صلاحية تعديل بيانات عائلة مؤقتة");
                        return;
                    }

                    string     Header = "مؤقت : " + tf.FamilyCode + " " + tf.FamilyName;
                    MainWindow m      = App.Current.MainWindow as MainWindow;
                    if (m.CheckTabControl(Header))
                    {
                        TabItem ti = new TabItem();
                        ti.Header = Header;
                        var tfc = new TempFamilyControl(tf);
                        ti.Content = tfc;

                        m.SendTabItem(ti);
                    }
                }
                else
                {
                    if (MyMessageBox.Show("تم تثبيت هذه العائلة \nهل تريد الانتقال الى البيانات التفصيليلة لها", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        if (!BaseDataBase.CurrentUser.CanUpdateFamily)
                        {
                            MyMessageBox.Show("ليس لديك صلاحية الانتقال للبيانات التفصيلية");
                            return;
                        }

                        var        f      = Family.GetFamilyByID(tf.FamilyID.Value);
                        string     Header = f.FamilyCode + " " + f.FamilyName;
                        MainWindow m      = App.Current.MainWindow as MainWindow;
                        if (m.CheckTabControl(Header))
                        {
                            TabItem ti = new TabItem();
                            ti.Header  = Header;
                            ti.Content = new AddFamilyControlHilal(f.FamilyID.Value);
                            m.SendTabItem(ti);
                        }
                    }
                }
            }
        }
示例#5
0
 public static bool DeleteData(TempFamily t)
 {
     foreach (var c in t.TempChilds)
     {
         TempChild.DeleteData(c);
     }
     return(BaseDataBase._StoredProcedure("sp_DeleteFromTempFamily"
                                          , new SqlParameter("@ID", t.ID)));
 }
示例#6
0
        public static bool InsertData(TempFamily t)
        {
            t.Creator = BaseDataBase.CurrentUser.Name;

            t.ID = BaseDataBase._StoredProcedureReturnable("sp_Add2TempFamily"
                                                           , new SqlParameter("@ID", System.Data.SqlDbType.Int)
                                                           , new SqlParameter("@FamilyName", t.FamilyName)
                                                           , new SqlParameter("@FamilyCode", t.FamilyCode)
                                                           , new SqlParameter("@ApplyDate", t.ApplyDate)
                                                           , new SqlParameter("@Notes", t.Notes)
                                                           , new SqlParameter("@FamilyType", t.FamilyType)
                                                           , new SqlParameter("@FamilyIdentityID", t.FamilyIdentityID)
                                                           , new SqlParameter("@FatherFirstName", t.FatherFirstName)
                                                           , new SqlParameter("@FatherFatherName", t.FatherFatherName)
                                                           , new SqlParameter("@FatherLastName", t.FatherLastName)
                                                           , new SqlParameter("@FatherBornPlace", t.FatherBornPlace)
                                                           , new SqlParameter("@FatherPID", t.FatherPID)
                                                           , new SqlParameter("@FatherDOB", t.FatherDOB)
                                                           , new SqlParameter("@MotherFirstName", t.MotherFirstName)
                                                           , new SqlParameter("@MotherFatherName", t.MotherFatherName)
                                                           , new SqlParameter("@MotherLastName", t.MotherLastName)
                                                           , new SqlParameter("@MotherBornPlace", t.MotherBornPlace)
                                                           , new SqlParameter("@MotherPID", t.MotherPID)
                                                           , new SqlParameter("@MotherDOB", t.MotherDOB)
                                                           , new SqlParameter("@Phone", t.Phone)
                                                           , new SqlParameter("@Mobile1", t.Mobile1)
                                                           , new SqlParameter("@Mobile2", t.Mobile2)
                                                           , new SqlParameter("@IsPrinted", t.IsPrinted)
                                                           , new SqlParameter("@Printer", t.Printer)
                                                           , new SqlParameter("@HouseSection", t.HouseSection)
                                                           , new SqlParameter("@HouseStreet", t.HouseStreet)
                                                           , new SqlParameter("@HouseBuildingNumber", t.HouseBuildingNumber)
                                                           , new SqlParameter("@HouseFloor", t.HouseFloor)
                                                           , new SqlParameter("@HouseAddress", t.HouseAddress)
                                                           , new SqlParameter("@HouseOldAddress", t.HouseOldAddress)
                                                           , new SqlParameter("@Creator", t.Creator)
                                                           , new SqlParameter("@IsCancelled", t.IsCancelled)
                                                           , new SqlParameter("@FamilyPersonCount", t.FamilyPersonCount)
                                                           , new SqlParameter("@CancelReason", t.CancelReason)
                                                           , new SqlParameter("@FamilyID", t.FamilyID)
                                                           );
            t.FamilyCode = BaseDataBase._Scalar("select FamilyCode from TempFamily where Id = " + t.ID);
            foreach (var tc in t.TempChilds)
            {
                tc.TempFamilyID = t.ID;
                TempChild.InsertData(tc);
            }

            return(t.ID.HasValue);
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            TempFamily tf = DataContext as TempFamily;

            if (tf != null)
            {
                if (chk.IsChecked == false)
                {
                    TempFamily.UpadteData(tf);
                    DialogResult = true;
                }
                else
                {
                    TempFamily.UpadteData(tf);
                    DialogResult = true;
                }
            }
        }
 private void btnCancelFamily_Click(object sender, RoutedEventArgs e)
 {
     if (dgTempFamilys.SelectedItem != null)
     {
         if (!BaseDataBase.CurrentUser.CanCancelTempFamily)
         {
             MyMessageBox.Show("ليس لديك صلاحيات للإلغاء");
         }
         else
         {
             var                    id = (int)(dgTempFamilys.SelectedItem as DataRowView)["ID"];
             TempFamily             tf = TempFamily.GetTempFamilyByID(id);
             CancelTempFamilyWindow w  = new CancelTempFamilyWindow(tf);
             if (w.ShowDialog() == true)
             {
                 (dgTempFamilys.Items[dgTempFamilys.SelectedIndex] as DataRowView).Row["IsCancelled"] = tf.IsCancelled;
                 dgTempFamilys.Items.Refresh();
             }
         }
     }
 }
示例#9
0
 public static bool UpadteData(TempFamily t)
 {
     return(BaseDataBase._StoredProcedure("sp_UpdateTempFamily"
                                          , new SqlParameter("@ID", t.ID)
                                          , new SqlParameter("@FamilyName", t.FamilyName)
                                          , new SqlParameter("@FamilyCode", t.FamilyCode)
                                          , new SqlParameter("@ApplyDate", t.ApplyDate)
                                          , new SqlParameter("@Notes", t.Notes)
                                          , new SqlParameter("@FamilyType", t.FamilyType)
                                          , new SqlParameter("@FamilyIdentityID", t.FamilyIdentityID)
                                          , new SqlParameter("@FatherFirstName", t.FatherFirstName)
                                          , new SqlParameter("@FatherFatherName", t.FatherFatherName)
                                          , new SqlParameter("@FatherLastName", t.FatherLastName)
                                          , new SqlParameter("@FatherBornPlace", t.FatherBornPlace)
                                          , new SqlParameter("@FatherPID", t.FatherPID)
                                          , new SqlParameter("@FatherDOB", t.FatherDOB)
                                          , new SqlParameter("@MotherFirstName", t.MotherFirstName)
                                          , new SqlParameter("@MotherFatherName", t.MotherFatherName)
                                          , new SqlParameter("@MotherLastName", t.MotherLastName)
                                          , new SqlParameter("@MotherBornPlace", t.MotherBornPlace)
                                          , new SqlParameter("@MotherPID", t.MotherPID)
                                          , new SqlParameter("@MotherDOB", t.MotherDOB)
                                          , new SqlParameter("@Phone", t.Phone)
                                          , new SqlParameter("@Mobile1", t.Mobile1)
                                          , new SqlParameter("@Mobile2", t.Mobile2)
                                          , new SqlParameter("@IsPrinted", t.IsPrinted)
                                          , new SqlParameter("@Printer", t.Printer)
                                          , new SqlParameter("@HouseSection", t.HouseSection)
                                          , new SqlParameter("@HouseStreet", t.HouseStreet)
                                          , new SqlParameter("@HouseBuildingNumber", t.HouseBuildingNumber)
                                          , new SqlParameter("@HouseFloor", t.HouseFloor)
                                          , new SqlParameter("@HouseAddress", t.HouseAddress)
                                          , new SqlParameter("@HouseOldAddress", t.HouseOldAddress)
                                          , new SqlParameter("@IsCancelled", t.IsCancelled)
                                          , new SqlParameter("@CancelReason", t.CancelReason)
                                          , new SqlParameter("@FamilyPersonCount", t.FamilyPersonCount)
                                          , new SqlParameter("@Creator", t.Creator)
                                          , new SqlParameter("@FamilyID", t.FamilyID)
                                          ));
 }
 private void btnDelTempFamily_Click(object sender, RoutedEventArgs e)
 {
     if (dgTempFamilys.SelectedIndex != -1)
     {
         if (!BaseDataBase.CurrentUser.CanDeleteTempFamily)
         {
             MyMessageBox.Show("ليس لديك صلاحيات للحذف");
         }
         else
         {
             if (MyMessageBox.Show("هل تريد تأكيد حذف العائلة المؤقتة", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 var        id = (int)(dgTempFamilys.SelectedItem as DataRowView)["ID"];
                 TempFamily tf = TempFamily.GetTempFamilyByID(id);
                 if (TempFamily.DeleteData(tf))
                 {
                     btnSearch_Click(null, null);
                     Control_Changed(null, null);
                     MyMessage.DeleteMessage();
                 }
             }
         }
     }
 }
 private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
     dt = dt2 = TempFamily.GetTempFamilyTable();
     SetItemsSource(1);
     Control_Changed(null, null);
 }
示例#12
0
        private void btnPrintAll_Click(object sender, RoutedEventArgs e)
        {
            if (cmboPrintType.SelectedIndex == 0)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.DefaultExt = ".xps";
                dlg.Filter     = "XPS Print Documents (.xps)|*.xps";

                if (dlg.ShowDialog() == true)
                {
                    tfs      = new List <TempFamily>();
                    FileName = dlg.FileName;
                    if (FileName.Substring(FileName.LastIndexOf('.'), FileName.Length - FileName.LastIndexOf('.')) != ".xps")
                    {
                        FileName += ".xps";
                    }
                    foreach (DataRowView item in dgmain.ItemsSource as DataView)
                    {
                        tfs.Add(TempFamily.GetTempFamilyByID((int)item[0]));
                    }
                    try
                    {
                        FixedDocument fd = new FixedDocument();
                        fd.DocumentPaginator.PageSize = new Size(1056, 768);
                        int index = 0;

                        foreach (var f in tfs)
                        {
                            index++;
                            var pc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "TempFamilyReportTemplate.xaml")) as PageContent;

                            if (pc != null)
                            {
                                pc.Child.Margin = new Thickness(25);
                                var img = pc.FindName("img") as Image;
                                if (img != null)
                                {
                                    img.Stretch = Stretch.Fill;
                                    BitmapImage bi = new BitmapImage();
                                    bi.BeginInit();
                                    bi.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute);
                                    bi.EndInit();
                                    img.Source = bi;
                                }
                                var txtUser = pc.FindName("txtUser") as TextBlock;
                                if (txtUser != null)
                                {
                                    txtUser.Text = BaseDataBase.CurrentUser.Name;
                                }

                                var txt = pc.FindName("txtMainDescription") as TextBlock;
                                if (txt != null)
                                {
                                    txt.Text = Properties.Settings.Default.ReportHeaderDescription;
                                }

                                var gridChild = pc.Child.FindName("grdChilds") as Grid;
                                if (gridChild != null)
                                {
                                    int i = 1;
                                    foreach (var tc in f.TempChilds)
                                    {
                                        TextBlock tb1 = new TextBlock();
                                        tb1.Text = tc.Name;
                                        tb1.SetValue(Grid.ColumnProperty, 1);
                                        tb1.SetValue(Grid.RowProperty, i);

                                        TextBlock tb2 = new TextBlock();
                                        tb2.Text = tc.Gender;
                                        tb2.SetValue(Grid.ColumnProperty, 2);
                                        tb2.SetValue(Grid.RowProperty, i);

                                        TextBlock tb3 = new TextBlock();
                                        tb3.Text = tc.DOB.Value.ToString("dd/MM/yyyy");
                                        tb3.SetValue(Grid.ColumnProperty, 4);
                                        tb3.SetValue(Grid.RowProperty, i);


                                        gridChild.Children.Add(tb1);
                                        gridChild.Children.Add(tb2);
                                        gridChild.Children.Add(tb3);
                                        i++;
                                    }
                                }

                                pc.Child.DataContext = null;
                                pc.Child.DataContext = f;
                                fd.Pages.Add(pc);
                            }
                        }
                        CreateXPSDocument(fd.DocumentPaginator, FileName);

                        foreach (var item in tfs)
                        {
                            item.Printer   = BaseDataBase.CurrentUser.Name;
                            item.IsPrinted = true;
                            TempFamily.UpadteData(item);
                        }
                        MyMessageBox.Show("تمت الطباعة بنجاح");
                    }
                    catch (Exception ex)
                    {
                        MyMessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.DefaultExt = ".xps";
                dlg.Filter     = "XPS Print Documents (.xps)|*.xps";

                if (dlg.ShowDialog() == true)
                {
                    fs       = new List <Family>();
                    FileName = dlg.FileName;
                    if (FileName.Substring(FileName.LastIndexOf('.'), FileName.Length - FileName.LastIndexOf('.')) != ".xps")
                    {
                        FileName += ".xps";
                    }
                    foreach (DataRowView item in dgmain.ItemsSource as DataView)
                    {
                        fs.Add(Family.GetFamilyByID((int)item[0]));
                    }
                    try
                    {
                        FixedDocument fd = new FixedDocument();
                        fd.DocumentPaginator.PageSize = new Size(1056, 768);
                        int index = 0;

                        foreach (var f in fs)
                        {
                            index++;
                            var pc = LoadTemplate(Path.Combine(Environment.CurrentDirectory, "FamilyReportTemplate.xaml")) as PageContent;

                            if (pc != null)
                            {
                                pc.Child.Margin = new Thickness(25);
                                var img = pc.FindName("img") as Image;
                                if (img != null)
                                {
                                    img.Stretch = Stretch.Fill;
                                    BitmapImage bi = new BitmapImage();
                                    bi.BeginInit();
                                    bi.UriSource = new Uri(Properties.Settings.Default.AssociationLogoPath, UriKind.RelativeOrAbsolute);
                                    bi.EndInit();
                                    img.Source = bi;
                                }
                                var txt = pc.FindName("txtMainDescription") as TextBlock;
                                if (txt != null)
                                {
                                    txt.Text = Properties.Settings.Default.ReportHeaderDescription;
                                }

                                var gridHouse = pc.Child.FindName("grdHouse") as Grid;
                                if (gridHouse != null)
                                {
                                    var hs = House.GetHouseAllByFamilyID(f.FamilyID);
                                    if (hs != null && hs.Count > 0)
                                    {
                                        gridHouse.DataContext = hs.Last();
                                    }
                                }
                                var gridChild = pc.Child.FindName("grdChilds") as Grid;
                                if (gridChild != null)
                                {
                                    int i = 1;
                                    foreach (var tc in FamilyPerson.GetFamilyPersonByFamilyID(f.FamilyID.Value))
                                    {
                                        TextBlock tb1 = new TextBlock();
                                        tb1.Text = tc.FirstName;
                                        tb1.SetValue(Grid.ColumnProperty, 1);
                                        tb1.SetValue(Grid.RowProperty, i);

                                        TextBlock tb2 = new TextBlock();
                                        tb2.Text = tc.Gender;
                                        tb2.SetValue(Grid.ColumnProperty, 2);
                                        tb2.SetValue(Grid.RowProperty, i);

                                        TextBlock tb3 = new TextBlock();
                                        tb3.Text = tc.RelationShip;
                                        tb3.SetValue(Grid.ColumnProperty, 3);
                                        tb3.SetValue(Grid.RowProperty, i);

                                        TextBlock tb4 = new TextBlock();
                                        tb4.Text = tc.DOB.Value.ToString("dd/MM/yyyy");
                                        tb4.SetValue(Grid.ColumnProperty, 4);
                                        tb4.SetValue(Grid.RowProperty, i);

                                        TextBlock tb5 = new TextBlock();
                                        tb5.Text = tc.StudyStatus;
                                        tb5.SetValue(Grid.ColumnProperty, 5);
                                        tb5.SetValue(Grid.RowProperty, i);

                                        TextBlock tb6 = new TextBlock();
                                        tb6.Text = tc.HealthStatus;
                                        tb6.SetValue(Grid.ColumnProperty, 6);
                                        tb6.SetValue(Grid.RowProperty, i);

                                        TextBlock tb7 = new TextBlock();
                                        tb7.Text = tc.MaritalStatus;
                                        tb7.SetValue(Grid.ColumnProperty, 7);
                                        tb7.SetValue(Grid.RowProperty, i);

                                        TextBlock tb8 = new TextBlock();
                                        tb8.Text = tc.Job;
                                        tb8.SetValue(Grid.ColumnProperty, 8);
                                        tb8.SetValue(Grid.RowProperty, i);

                                        gridChild.Children.Add(tb1);
                                        gridChild.Children.Add(tb2);
                                        gridChild.Children.Add(tb3);
                                        gridChild.Children.Add(tb4);
                                        gridChild.Children.Add(tb5);
                                        gridChild.Children.Add(tb6);
                                        gridChild.Children.Add(tb7);
                                        gridChild.Children.Add(tb8);
                                        i++;
                                    }
                                }

                                pc.Child.DataContext = null;
                                pc.Child.DataContext = f;
                                fd.Pages.Add(pc);
                            }
                        }
                        CreateXPSDocument(fd.DocumentPaginator, FileName);

                        MyMessageBox.Show("تمت الطباعة بنجاح");
                    }
                    catch (Exception ex)
                    {
                        MyMessageBox.Show(ex.Message);
                    }
                }
            }
        }
示例#13
0
        public static List <TempFamily> GetTempFamilyAll()
        {
            List <TempFamily> tfs = new List <TempFamily>();
            SqlConnection     con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand        com = new SqlCommand("sp_GetTempFamilyAll", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    TempFamily x = new TempFamily();

                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = System.Int32.Parse(rd["ID"].ToString());
                    }
                    x.FamilyName = rd["FamilyName"].ToString();
                    x.FamilyCode = rd["FamilyCode"].ToString();
                    if (!(rd["ApplyDate"] is DBNull))
                    {
                        x.ApplyDate = System.DateTime.Parse(rd["ApplyDate"].ToString());
                    }
                    x.FamilyIdentityID = rd["FamilyIdentityID"].ToString();
                    if (!(rd["FamilyPersonCount"] is DBNull))
                    {
                        x.FamilyPersonCount = System.Int32.Parse(rd["FamilyPersonCount"].ToString());
                    }
                    x.Notes            = rd["Notes"].ToString();
                    x.FamilyType       = rd["FamilyType"].ToString();
                    x.FatherFirstName  = rd["FatherFirstName"].ToString();
                    x.FatherFatherName = rd["FatherFatherName"].ToString();
                    x.FatherLastName   = rd["FatherLastName"].ToString();
                    x.FatherBornPlace  = rd["FatherBornPlace"].ToString();
                    x.FatherPID        = rd["FatherPID"].ToString();
                    if (!(rd["FatherDOB"] is DBNull))
                    {
                        x.FatherDOB = System.DateTime.Parse(rd["FatherDOB"].ToString());
                    }
                    x.MotherFirstName  = rd["MotherFirstName"].ToString();
                    x.MotherFatherName = rd["MotherFatherName"].ToString();
                    x.MotherLastName   = rd["MotherLastName"].ToString();
                    x.MotherBornPlace  = rd["MotherBornPlace"].ToString();
                    x.MotherPID        = rd["MotherPID"].ToString();
                    if (!(rd["MotherDOB"] is DBNull))
                    {
                        x.MotherDOB = System.DateTime.Parse(rd["MotherDOB"].ToString());
                    }
                    x.Phone   = rd["Phone"].ToString();
                    x.Mobile1 = rd["Mobile1"].ToString();
                    x.Mobile2 = rd["Mobile2"].ToString();
                    if (!(rd["IsPrinted"] is DBNull))
                    {
                        x.IsPrinted = System.Boolean.Parse(rd["IsPrinted"].ToString());
                    }
                    x.Printer             = rd["Printer"].ToString();
                    x.HouseSection        = rd["HouseSection"].ToString();
                    x.HouseStreet         = rd["HouseStreet"].ToString();
                    x.HouseBuildingNumber = rd["HouseBuildingNumber"].ToString();
                    x.HouseFloor          = rd["HouseFloor"].ToString();
                    x.HouseAddress        = rd["HouseAddress"].ToString();
                    x.HouseOldAddress     = rd["HouseOldAddress"].ToString();
                    if (!(rd["IsCancelled"] is DBNull))
                    {
                        x.IsCancelled = System.Boolean.Parse(rd["IsCancelled"].ToString());
                    }
                    x.CancelReason = rd["CancelReason"].ToString();
                    x.Creator      = rd["Creator"].ToString();
                    if (!(rd["FamilyID"] is DBNull))
                    {
                        x.FamilyID = System.Int32.Parse(rd["FamilyID"].ToString());
                    }

                    x.TempChilds = TempChild.GetTempChildsByTempFamilyID(x.ID.Value);

                    tfs.Add(x);
                }
                rd.Close();
            }
            catch
            {
                tfs = new List <TempFamily>();
            }
            finally
            {
                con.Close();
            }
            return(tfs);
        }
 public CancelTempFamilyWindow(TempFamily tf)
 {
     InitializeComponent();
     this.DataContext = tf;
 }
示例#15
0
        private void btnExecute_Click(object sender, RoutedEventArgs e)
        {
            MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            var f = cFamily.DataContext as Family;

            if (f.IsValidate())
            {
                if (!(string.IsNullOrEmpty(f.FamilyFather.FirstName) && string.IsNullOrEmpty(f.FamilyFather.LastName)))
                {
                    if (!f.FamilyFather.IsValidate())
                    {
                        return;
                    }
                }
                if (!(string.IsNullOrEmpty(f.FamilyMother.FirstName) && string.IsNullOrEmpty(f.FamilyMother.LastName)))
                {
                    if (!f.FamilyMother.IsValidate())
                    {
                        return;
                    }
                }
                if (!string.IsNullOrEmpty(f.FamilyHouse.OldAddress) || !string.IsNullOrEmpty(f.FamilyHouse.Address))
                {
                    if (!f.FamilyHouse.IsValidate())
                    {
                        return;
                    }
                }
                foreach (var fp in cFamily.dgChild.ItemsSource as List <FamilyPerson> )
                {
                    if (!fp.IsValidate())
                    {
                        return;
                    }
                }


                string a = (cFamily.cmboSector.SelectedItem as Sector).Code;
                string s = a + BaseDataBase._Scalar_StoredProcedure("sp_GetMaxFamilyCodeByChar", new SqlParameter("@char", a));
                f.FamilyCode = s;

                if (DBMain.InsertData(f))
                {
                    var tih = this.Parent as TabItem;
                    if (tih != null)
                    {
                        tih.Header = f.FamilyCode + " " + f.FamilyName;
                    }

                    if (tf != null)
                    {
                        tf.FamilyID = f.FamilyID;
                        TempFamily.UpadteData(tf);
                    }
                    if (!(string.IsNullOrEmpty(f.FamilyFather.FirstName) && string.IsNullOrEmpty(f.FamilyFather.LastName)))
                    {
                        DBMain.InsertData(f.FamilyFather);
                    }

                    if (!(string.IsNullOrEmpty(f.FamilyMother.FirstName) && string.IsNullOrEmpty(f.FamilyMother.LastName)))
                    {
                        DBMain.InsertData(f.FamilyMother);
                    }

                    f.FamilyHouse.FamilyID = f.FamilyID;
                    if (!string.IsNullOrEmpty(f.FamilyHouse.OldAddress) || !string.IsNullOrEmpty(f.FamilyHouse.HouseSection))
                    {
                        DBMain.InsertData(f.FamilyHouse);
                    }

                    foreach (var fp in cFamily.dgChild.ItemsSource as List <FamilyPerson> )
                    {
                        if (f.FamilyID.HasValue && !fp.FamilyPersonID.HasValue)
                        {
                            fp.FamilyID = f.FamilyID;
                            DBMain.InsertData(fp);
                        }
                    }

                    btnUpdate.Visibility  = System.Windows.Visibility.Visible;
                    btnExecute.Visibility = System.Windows.Visibility.Collapsed;

                    cFamilyNeed.FamilyID            = f.FamilyID;
                    cExternalFamilySupport.FamilyID = f.FamilyID;
                    cSpecialCard.FamilyID           = f.FamilyID;
                    cListerGroup.FamilyID           = f.FamilyID;
                    cAdminEvaluation.FamilyID       = f.FamilyID;
                    cOrders.FamilyID = f.FamilyID;

                    f.UpdateFamilyPersonCount();
                    EnableTabs();
                    MyMessage.InsertMessage();
                }
            }
        }
示例#16
0
        public AddFamilyControlHilal(TempFamily tf)
        {
            InitializeComponent();
            DisableTabs();
            this.tf = tf;

            //Family
            Family f = new Family();

            //f.FamilyCode = tf.FamilyCode;
            f.FamilyName         = tf.FamilyName;
            f.FamilyType         = tf.FamilyType;
            f.ApplyDate          = tf.ApplyDate;
            f.Notes              = tf.Notes;
            f.FamilyPersonCount  = tf.FamilyPersonCount.ToString();
            f.FamilyIdentityID   = tf.FamilyIdentityID;
            f.DefinedPersonPhone = tf.Phone;
            cFamily.DataContext  = f;

            //Father
            f.FamilyFather.FirstName  = tf.FatherFirstName;
            f.FamilyFather.FatherName = tf.FatherFatherName;
            f.FamilyFather.LastName   = tf.FatherLastName;
            f.FamilyFather.DOB        = tf.FatherDOB;
            f.FamilyFather.BirthPlace = tf.FatherBornPlace;
            f.FamilyFather.PID        = tf.FatherPID;
            f.FamilyFather.Phone      = tf.Phone;
            f.FamilyFather.Mobile     = tf.Mobile1;

            //Mother
            f.FamilyMother.FirstName  = tf.MotherFirstName;
            f.FamilyMother.FatherName = tf.MotherFatherName;
            f.FamilyMother.LastName   = tf.MotherLastName;
            f.FamilyMother.DOB        = tf.MotherDOB;
            f.FamilyMother.BirthPlace = tf.MotherBornPlace;
            f.FamilyMother.PID        = tf.MotherPID;
            f.FamilyMother.Phone      = tf.Phone;
            f.FamilyMother.Mobile     = tf.Mobile2;

            //House
            House h = new House();

            h.Phone               = tf.Phone;
            h.HouseSection        = tf.HouseSection;
            h.HouseStreet         = tf.HouseStreet;
            h.Address             = tf.HouseAddress;
            h.OldAddress          = tf.HouseOldAddress;
            h.HouseBuildingNumber = tf.HouseBuildingNumber;
            h.HouseFloor          = tf.HouseFloor;
            f.FamilyHouse         = h;

            List <FamilyPerson> chlds = new List <FamilyPerson>();

            foreach (var c in tf.TempChilds)
            {
                chlds.Add(new FamilyPerson()
                {
                    FirstName = c.Name, DOB = c.DOB, Gender = c.Gender, RelationShip = c.Gender == "ذكر" ? "ابن" : "ابنة"
                });
            }
            cFamily.dgChild.ItemsSource = (from x in chlds orderby x.DOB select x).ToList();

            cFamily.UserControl_Loaded(null, null);

            var sb = cFamily.FindResource("sbShowDetails") as Storyboard;

            if (sb != null)
            {
                sb.Begin(cFamily);
            }
        }