예제 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!(BaseDataBase.CurrentUser.CanUpdateFamily || BaseDataBase.CurrentUser.PointAdmin))
            {
                MessageBox.Show("ليس لديك صلاحية اضافة بطافة خاصة");
                return;
            }
            var x = this.DataContext as SpecialCardSource;

            if (x.IsValidate())
            {
                if (x.Id.HasValue)
                {
                    if (!BaseDataBase.CurrentUser.PointAdmin)
                    {
                        MessageBox.Show("ليس لديك صلاحية تعديل بطافة خاصة");
                        return;
                    }
                    if (BaseDataBase.CurrentUser.CanUpdate && SpecialCardSource.UpdateData(x))
                    {
                        MyMessage.UpdateMessage();
                    }
                }
                else
                {
                    if (SpecialCardSource.InsertData(x))
                    {
                        MyMessage.InsertMessage();
                        SpecialCardSources.Add(x);
                        TotalCount = SpecialCardSources.Count;
                        Place      = TotalCount;
                    }
                }
            }
        }
예제 #2
0
 public static bool UpdateData(SpecialCardSource x)
 {
     return(BaseDataBase._StoredProcedure("sp_Update_SpecialCardSource"
                                          , new SqlParameter("@Id", x.Id)
                                          , new SqlParameter("@SpecialCardID", x.SpecialCardID)
                                          , new SqlParameter("@CenterID", x.CenterID)
                                          , new SqlParameter("@BeneficiaryType", x.BeneficiaryType)
                                          , new SqlParameter("@BeneficiaryID", x.BeneficiaryID)
                                          , new SqlParameter("@StartDate", x.StartDate)
                                          , new SqlParameter("@EndDate", x.EndDate)
                                          , new SqlParameter("@Notes", x.Notes)
                                          , new SqlParameter("@Code", x.Code)
                                          , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID)));
 }
예제 #3
0
 public static bool InsertData(SpecialCardSource x)
 {
     x.Id = BaseDataBase._StoredProcedureReturnable("sp_Add_SpecialCardSource"
                                                    , new SqlParameter("@Id", System.Data.SqlDbType.Int)
                                                    , new SqlParameter("@SpecialCardID", x.SpecialCardID)
                                                    , new SqlParameter("@CenterID", x.CenterID)
                                                    , new SqlParameter("@BeneficiaryType", x.BeneficiaryType)
                                                    , new SqlParameter("@BeneficiaryID", x.BeneficiaryID)
                                                    , new SqlParameter("@StartDate", x.StartDate)
                                                    , new SqlParameter("@EndDate", x.EndDate)
                                                    , new SqlParameter("@Notes", x.Notes)
                                                    , new SqlParameter("@Code", x.Code)
                                                    , new SqlParameter("@LastUserID", BaseDataBase.CurrentUser.ID));
     return(x.Id.HasValue);
 }
예제 #4
0
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as SpecialCardSource;

            if (x == null || x.Id.HasValue)
            {
                try
                {
                    var MaxEndDate = SpecialCardSources.Select(s => s.EndDate).Max().Value;
                    if (BaseDataBase.DateNow < MaxEndDate)
                    {
                        MyMessageBox.Show("تاريخ نهاية البطاقة السابقة هو " + MaxEndDate.ToShortDateString());
                        return;
                    }
                }
                catch { }
                var scs = new SpecialCardSource();
                scs.StartDate    = BaseDataBase.DateNow;
                scs.EndDate      = scs.StartDate.Value.AddDays(120);
                this.DataContext = scs;
            }
        }
예제 #5
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as SpecialCardSource;

            if (x.Id.HasValue)
            {
                if (!BaseDataBase.CurrentUser.PointAdmin)
                {
                    MyMessageBox.Show("لا يوجد لديك صلاحيات للحذف");
                }
                else if (MyMessageBox.Show("هل تريد تأكيد حذف البيانات", MessageBoxButton.YesNo) == MessageBoxResult.Yes && SpecialCardSource.DeleteData(x))
                {
                    MyMessage.DeleteMessage();
                    FamilyID = FamilyID;
                }
            }
        }
예제 #6
0
        public static List <SpecialCardSource> GetAllSpecialCardSourcByFamilyID(int FamilyID)
        {
            List <SpecialCardSource> xx  = new List <SpecialCardSource>();
            SqlConnection            con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand com = new SqlCommand("sp_Get_FamilyID_SpecialCardSource", con);

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

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                while (rd.Read())
                {
                    SpecialCardSource x = new SpecialCardSource();

                    if (!(rd["Id"] is DBNull))
                    {
                        x.Id = int.Parse(rd["Id"].ToString());
                    }
                    if (!(rd["SpecialCardID"] is DBNull))
                    {
                        x.SpecialCardID = int.Parse(rd["SpecialCardID"].ToString());
                    }
                    if (!(rd["CenterID"] is DBNull))
                    {
                        x.CenterID = int.Parse(rd["CenterID"].ToString());
                    }
                    if (!(rd["BeneficiaryType"] is DBNull))
                    {
                        x.BeneficiaryType = int.Parse(rd["BeneficiaryType"].ToString());
                    }
                    if (!(rd["BeneficiaryID"] is DBNull))
                    {
                        x.BeneficiaryID = int.Parse(rd["BeneficiaryID"].ToString());
                    }
                    if (!(rd["StartDate"] is DBNull))
                    {
                        x.StartDate = DateTime.Parse(rd["StartDate"].ToString());
                    }
                    if (!(rd["EndDate"] is DBNull))
                    {
                        x.EndDate = DateTime.Parse(rd["EndDate"].ToString());
                    }
                    if (!(rd["LastUserID"] is DBNull))
                    {
                        x.LastUserID = int.Parse(rd["LastUserID"].ToString());
                    }
                    x.Notes = rd["Notes"].ToString();
                    x.Code  = rd["Code"].ToString();
                    xx.Add(x);
                }
                rd.Close();
            }
            catch
            {
                xx = new List <MainWPF.SpecialCardSource>();
            }
            finally
            {
                con.Close();
            }
            return(xx);
        }
예제 #7
0
 public static bool DeleteData(SpecialCardSource x)
 {
     return(BaseDataBase._StoredProcedure("sp_Delete_SpecialCardSource"
                                          , new SqlParameter("@Id", x.Id)));
 }