private void dgCard_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
 {
     if (e.EditAction == DataGridEditAction.Commit)
     {
         var c = e.Row.DataContext as SpecialCard;
         if (c != null && c.IsValidate())
         {
             if (!c.ID.HasValue)
             {
                 if (SpecialCard.InsertData(c))
                 {
                     MyMessage.InsertMessage();
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
             else
             {
                 if (SpecialCard.UpdateData(c))
                 {
                     MyMessage.UpdateMessage();
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public SpecialCardControl()
 {
     InitializeComponent();
     cmboType.ItemsSource        = SpecialCardSource.Types;
     cmboSpecialCard.ItemsSource = SpecialCard.GetAllSpecialCard().Where(x => x.IsActive).ToList();
     cmboCenter.ItemsSource      = SpecialCardCenter.GetAllSpecialCardCenter().Where(x => x.IsActive).ToList();
 }
Ejemplo n.º 3
0
 public static bool UpdateData(SpecialCard x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_SpecialCard"
                                          , new SqlParameter("@ID", x.ID)
                                          , new SqlParameter("@Name", x.Name)
                                          , new SqlParameter("@IsActive", x.IsActive)
                                          , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)));
 }
Ejemplo n.º 4
0
 public static bool InsertData(SpecialCard x)
 {
     x.ID = BaseDataBase._StoredProcedureReturnable("sp_Add_SpecialCard"
                                                    , new SqlParameter("@ID", System.Data.SqlDbType.Int)
                                                    , new SqlParameter("@Name", x.Name)
                                                    , new SqlParameter("@IsActive", x.IsActive)
                                                    , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID));
     return(x.ID.HasValue);
 }
Ejemplo n.º 5
0
        public static SpecialCard GetSpecialCardByID(int id)
        {
            SpecialCard   x   = new SpecialCard();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_Get_ID_SpecialCard", 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();
                    if (!(rd["IsActive"] is DBNull))
                    {
                        x.IsActive = bool.Parse(rd["IsActive"].ToString());
                    }
                    if (!(rd["LastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["LastUserID"].ToString());
                    }
                }
                rd.Close();
            }
            catch
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }
Ejemplo n.º 6
0
        public static List <SpecialCard> GetAllSpecialCard()
        {
            List <SpecialCard> xx  = new List <SpecialCard>();
            SqlConnection      con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand         com = new SqlCommand("sp_Get_All_SpecialCard", con);

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

                    if (!(rd["ID"] is DBNull))
                    {
                        x.ID = int.Parse(rd["ID"].ToString());
                    }
                    x.Name = rd["Name"].ToString();
                    if (!(rd["IsActive"] is DBNull))
                    {
                        x.IsActive = bool.Parse(rd["IsActive"].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);
        }
        private void btnDeleteCard_Click(object sender, RoutedEventArgs e)
        {
            var c = dgCard.SelectedItem as SpecialCard;

            if (c != null)
            {
                if (c.CanRemove())
                {
                    if (SpecialCard.DeleteData(c))
                    {
                        dgCard.ItemsSource = null;
                        dgCard.ItemsSource = SpecialCard.GetAllSpecialCard();
                        MyMessage.DeleteMessage();
                    }
                }
                else
                {
                    MyMessageBox.Show("لايمكن حذف البطاقة الخاصة بسبب وجود بطاقات مرتبطة بالعوائل او الافراد");
                }
            }
        }
Ejemplo n.º 8
0
 public static bool DeleteData(SpecialCard x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_SpecialCard"
                                          , new SqlParameter("@ID", x.ID)));
 }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     dgCard.ItemsSource   = SpecialCard.GetAllSpecialCard();
     dgCenter.ItemsSource = SpecialCardCenter.GetAllSpecialCardCenter();
 }