コード例 #1
0
 private void dgCenter_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
 {
     if (e.EditAction == DataGridEditAction.Commit)
     {
         var c = e.Row.DataContext as SpecialCardCenter;
         if (c != null && c.IsValidate())
         {
             if (!c.Id.HasValue)
             {
                 if (SpecialCardCenter.InsertData(c))
                 {
                     MyMessage.InsertMessage();
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
             else
             {
                 if (SpecialCardCenter.UpdateData(c))
                 {
                     MyMessage.UpdateMessage();
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
         }
     }
 }
コード例 #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();
 }
コード例 #3
0
 public static bool UpdateData(SpecialCardCenter x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_SpecialCardCenter"
                                          , new SqlParameter("@Id", x.Id)
                                          , new SqlParameter("@Name", x.Name)
                                          , new SqlParameter("@IsActive", x.IsActive)
                                          , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)));
 }
コード例 #4
0
 public static bool InsertData(SpecialCardCenter x)
 {
     x.Id = BaseDataBase._StoredProcedureReturnable("sp_Add_SpecialCardCenter"
                                                    , 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);
 }
コード例 #5
0
        public static List <SpecialCardCenter> GetAllSpecialCardCenter()
        {
            List <SpecialCardCenter> xx  = new List <SpecialCardCenter>();
            SqlConnection            con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand com = new SqlCommand("sp_Get_All_SpecialCardCenter", con);

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

                    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);
        }
コード例 #6
0
        public static SpecialCardCenter GetSpecialCardCenterByID(int id)
        {
            SpecialCardCenter x   = new SpecialCardCenter();
            SqlConnection     con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand        com = new SqlCommand("sp_Get_ID_SpecialCardCenter", 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);
        }
コード例 #7
0
        private void btnDeleteCenter_Click(object sender, RoutedEventArgs e)
        {
            var c = dgCenter.SelectedItem as SpecialCardCenter;

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