Beispiel #1
0
 public static bool UpdateData(TempChild tc)
 {
     return(BaseDataBase._StoredProcedure("sp_UpdateTempChild"
                                          , new SqlParameter("@ChildID", tc.ChildID)
                                          , new SqlParameter("@TempFamilyID", tc.TempFamilyID)
                                          , new SqlParameter("@Name", tc.Name)
                                          , new SqlParameter("@DOB", tc.DOB)
                                          , new SqlParameter("@Gender", tc.Gender)));
 }
Beispiel #2
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)));
 }
        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();
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public static bool InsertData(TempChild tc)
        {
            tc.ChildID = BaseDataBase._StoredProcedureReturnable("sp_Add2TempChild"
                                                                 , new SqlParameter("@ChildID", System.Data.SqlDbType.Int)
                                                                 , new SqlParameter("@TempFamilyID", tc.TempFamilyID)
                                                                 , new SqlParameter("@Name", tc.Name)
                                                                 , new SqlParameter("@DOB", tc.DOB)
                                                                 , new SqlParameter("@Gender", tc.Gender));

            return(tc.ChildID.HasValue);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public static List <TempChild> GetTempChildsByTempFamilyID(int id)
        {
            List <TempChild> tcs = new List <TempChild>();

            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_GetTempChildsAllByTempFamilyID", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            SqlParameter pr = new SqlParameter("@TempFamilyID", id);

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    TempChild tc = new TempChild();
                    if (!(rd["ChildID"] is DBNull))
                    {
                        tc.ChildID = System.Int32.Parse(rd["ChildID"].ToString());
                    }
                    tc.Name   = rd["Name"].ToString();
                    tc.Gender = rd["Gender"].ToString();
                    if (!(rd["DOB"] is DBNull))
                    {
                        tc.DOB = System.DateTime.Parse(rd["DOB"].ToString());
                    }

                    tcs.Add(tc);
                }
                rd.Close();
            }
            catch
            {
                tcs = new List <TempChild>();
            }
            finally
            {
                con.Close();
            }
            return(tcs);
        }
Beispiel #7
0
 public static bool DeleteData(TempChild tc)
 {
     return(BaseDataBase._StoredProcedure("sp_DeleteFromTempChild"
                                          , new SqlParameter("@ChildID", tc.ChildID)));
 }
Beispiel #8
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);
        }