private void btnSave_Click(object sender, EventArgs e)
        {
            if (!checkData())
            {
                return;
            }
            else
            {
                String roomTypeName = Utils.standardNamePerson(txtRoomTypeName.Text);
                roomTypeObject = new DTORoomType("LP0000000", roomTypeName);

                if (roomTypeBUS.InsertRoomType(roomTypeObject))
                {
                    XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    btnAdd.Enabled       = true;
                    btnCancelAdd.Enabled = false;
                    btnCancelAdd.Visible = false;
                    btnSave.Enabled      = false;
                }
                else
                {
                    XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                }
            }
        }
Esempio n. 2
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String  roomTypeName   = Utils.standardNamePerson(txtRoomTypeName.Text);
                    decimal roomTypePrices = Math.Round(spPrices.Value);
                    roomTypeObject = new DTORoomType("LP00000000", roomTypeName, roomTypePrices);

                    if (roomTypeBUS.InsertRoomType(roomTypeObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String  roomTypeName   = Utils.standardNamePerson(txtRoomTypeName.Text);
                    decimal roomTypePrices = Math.Round(spPrices.Value);
                    roomTypeObject = new DTORoomType(txtRoomTypeId.Text, roomTypeName, roomTypePrices);

                    if (roomTypeBUS.UpdateRoomType(roomTypeObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }