Exemple #1
0
 public bool Update(ProgramClassRoom obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Exemple #2
0
 public int Add(ProgramClassRoom obj)
 {
     try
     {
         _db.ProgramClassRooms.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.ProgramClassRooms.Max(x => x.ProgramClassRoomId));
 }
Exemple #3
0
        protected void ToolbarClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "New")
            {
                Grid.SelectedIndexes.Clear();
                ResetForm();
            }
            if (e.Item.Text == "Save")
            {
                var cRoom = new CProgramClassRoom();
                var room  = new Erp2016.Lib.ProgramClassRoom();

                room.SiteLocationId = CurrentSiteLocationId;
                room.Name           = tbName.Text;
                room.Number         = tbNumber.Text;
                room.Floor          = tbFloor.Text;

                if (tbCapacity.Value != null)
                {
                    room.Capacity = Convert.ToInt32(tbCapacity.Value);
                }
                else
                {
                    room.Capacity = null;
                }

                room.CreatedId   = CurrentUserId;
                room.CreatedDate = DateTime.Now;
                room.Description = RadTextBoxDescription.Text;
                room.IsActive    = RadButtonActive.Checked;

                int result = cRoom.Add(room);
                if (result > 0)
                {
                    SetProgramClassRoomDetails(result);

                    ShowMessage("New class room is added");

                    Grid.Rebind();
                }
                else
                {
                    ShowMessage("Failed to add class room, please try again");
                }
            }
            if (e.Item.Text == "Update")
            {
                if (Grid.SelectedValue != null)
                {
                    var cRoom = new CProgramClassRoom();
                    var room  = cRoom.Get(Convert.ToInt32(Grid.SelectedValue));

                    room.Name   = tbName.Text;
                    room.Number = tbNumber.Text;
                    room.Floor  = tbFloor.Text;

                    if (tbCapacity.Value != null)
                    {
                        room.Capacity = Convert.ToInt32(tbCapacity.Value);
                    }
                    else
                    {
                        room.Capacity = null;
                    }

                    room.Description = RadTextBoxDescription.Text;
                    room.IsActive    = RadButtonActive.Checked;

                    if (cRoom.Update(room))
                    {
                        SetProgramClassRoomDetails(room.ProgramClassRoomId);

                        ShowMessage("Classroom updated");

                        Grid.Rebind();
                    }
                    else
                    {
                        ShowMessage("Failed to update class room, please try again");
                    }
                }
            }
        }