예제 #1
1
        public bool Insert(School school, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_SchoolInsert");

            db.AddInParameter(command, "SchoolId", DbType.Guid, Guid.NewGuid());
            db.AddInParameter(command, "Name", DbType.String, school.Name);
            db.AddInParameter(command, "StreetAddress", DbType.String, school.StreetAddress);
            db.AddInParameter(command, "City", DbType.String, school.City);
            db.AddInParameter(command, "State", DbType.String, school.State);
            db.AddInParameter(command, "Zip", DbType.String, school.Zip);
            db.AddInParameter(command, "ContactNumber", DbType.String, school.ContactNumber);
            db.AddInParameter(command, "Email", DbType.String, school.Email);
            db.AddInParameter(command, "Location", DbType.String, school.Location);
            db.AddInParameter(command, "WebsiteURL", DbType.String, school.WebsiteURL);
            db.AddInParameter(command, "RatingValue", DbType.Decimal, school.RatingValue);
            db.AddInParameter(command, "CreatedBy", DbType.Guid, school.CreatedBy);

            db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }

            school.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
            school.UpdatedDate = school.CreatedDate;

            return true;
        }
예제 #2
0
        public bool Delete(School school, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_SchoolDelete");
            db.AddInParameter(command, "SchoolId", DbType.Guid, school.SchoolId);
            db.AddInParameter(command, "UpdatedBy", DbType.Guid, school.UpdatedBy);

            if (transaction == null)
            {
                db.ExecuteNonQuery(command);
            }
            else
            {
                db.ExecuteNonQuery(command, transaction);
            }
            return true;
        }
예제 #3
0
        protected void gvSchoolList_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            School school = new School();

            int i = gvSchoolList.FindVisibleIndexByKeyValue(e.Keys[gvSchoolList.KeyFieldName]);
            e.Cancel = true;

            school.SchoolId = (Guid)e.Keys[gvSchoolList.KeyFieldName];

            if (new SchoolDAO().Delete(school))
            {
                //Show Success message
            }
            else
            {
                //Error message
            }

            Session[Constants.SESSION_SCHOOL_LIST] = new SchoolDAO().SelectAllDataset();
            LoadGrid();
        }
예제 #4
0
 public bool Update(School school)
 {
     Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
     return this.Update(school, db, null);
 }
예제 #5
0
        protected void gvSchoolList_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxGridView gridView = sender as ASPxGridView;

            School school = new School();
            school.Name = GetColumnValue(e.NewValues["Name"]);
            school.State = GetColumnValue(e.NewValues["State"]);
            school.StreetAddress = GetColumnValue(e.NewValues["StreetAddress"]);
            school.WebsiteURL = GetColumnValue(e.NewValues["WebsiteURL"]);
               // school.Year = GetColumnValue(e.NewValues["Year"]);
            school.Zip = GetColumnValue(e.NewValues["Zip"]);
            school.City = GetColumnValue(e.NewValues["City"]);
            school.ContactNumber = GetColumnValue(e.NewValues["ContactNumber"]);
            school.CreatedBy = (Guid)Membership.GetUser().ProviderUserKey;
            school.Email = GetColumnValue(e.NewValues["Email"]);
            school.RatingValue = e.NewValues["RatingValue"] == null ? decimal.Zero : (decimal)e.NewValues["RatingValue"];

            gridView.CancelEdit();
            e.Cancel = true;

            if (school.Save())
            {
                //Show Success message
            }
            else
            {
                //Error message
            }

            Session[Constants.SESSION_SCHOOL_LIST] = new SchoolDAO().SelectAllDataset();
            LoadGrid();
        }