Ejemplo n.º 1
0
        private void btnChild_Click(object sender, RoutedEventArgs e)
        {
            var tf = this.DataContext as TempFamily;
            var tc = grdChild.DataContext as TempChild;

            if (tc == null)
            {
                return;
            }
            if (radDel.IsChecked == true)
            {
                if (MyMessageBox.Show("هل تريد تأكيد الحذف", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (!tc.ChildID.HasValue || TempChild.DeleteData(tc))
                    {
                        tf.TempChilds.Remove(tc);
                        dgChild.Items.Refresh();
                        MyMessage.DeleteMessage();
                        radAdd.IsChecked = true;
                    }
                }
            }
            else
            {
                if (tc.IsValidate())
                {
                    if (radAdd.IsChecked == true)
                    {
                        tc.TempFamilyID = tf.ID;
                        if (!tf.ID.HasValue || TempChild.InsertData(tc))
                        {
                            tf.TempChilds.Add(tc);
                            dgChild.Items.Refresh();
                            grdChild.DataContext = new TempChild();
                            Keyboard.Focus(txtChildName);
                            if (tf.ID.HasValue)
                            {
                                MyMessage.InsertMessage();
                            }
                        }
                    }
                    else
                    {
                        tc.TempFamilyID = tf.ID;
                        if (!tf.ID.HasValue || TempChild.UpdateData(tc))
                        {
                            dgChild.Items.Refresh();
                            if (tf.ID.HasValue)
                            {
                                MyMessage.UpdateMessage();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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);
        }