Example #1
0
 public bool addRoomType(RoomType rt, out string roomTypeId)
 {
     var result = roomTypeDAT.addRoomType(rt);
     if (result.Rows[0].ItemArray[0].ToString() == "0")
     {
         roomTypeId = result.Rows[0].ItemArray[1].ToString();
         return true;
     }
     roomTypeId = "";
     return false;
 }
Example #2
0
 public RoomTypeEdit(RoomType roomType)
 {
     InitializeComponent();
     this.roomTypeBLT = new RoomTypeBLT();
     this.Text = "Edit room type";
     txtId.Text = roomType.Id;
     txtName.Text = roomType.Name;
     txtPrice.Text = roomType.Price.ToString();
     txtDeposit.Text = roomType.Deposit.ToString();
     txtNote.Text = roomType.Note;
 }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (checkContraints())
            {
                RoomType rt = new RoomType()
                {
                    Id = txtId.Text,
                    Name = txtName.Text.Trim(),
                    Price = decimal.Parse(txtPrice.Text.Trim() == "" ? "0" : txtPrice.Text.Trim()),
                    Deposit = decimal.Parse(txtDeposit.Text.Trim() == "" ? "0" : txtDeposit.Text.Trim()),
                    Note = txtNote.Text.Trim()
                };

                if (this.Text == "Edit room type")
                {
                    //Edit
                    if(roomTypeBLT.updateRoomType(rt))
                    {
                        MessageBox.Show("Update " + txtId.Text.Trim().ToUpper() + " successfully!");
                        EditCompletedHandler(txtId.Text.Trim());
                        this.Close();
                    }
                    else
                        MessageBox.Show("Update " + txtId.Text.ToUpper() + " fail!");
                }
                else
                {
                    //Insert
                    string id;
                    if (roomTypeBLT.addRoomType(rt, out id))
                    {
                        MessageBox.Show("Insert " + txtName.Text.Trim().ToUpper() + " successfully!\nThe new room type Id = " + id + ".");
                        EditCompletedHandler(id);
                        this.Close();
                    }
                    else
                        MessageBox.Show("Insert " + txtId.Text.ToUpper() + " fail! Try again later.");
                }
            }
        }
        public DataTable addRoomType(RoomType rt)
        {
            try
            {
                int param = 4;

                string[] name = new string[param];
                object[] value = new object[param];

                name[0] = "@p_NAME"; value[0] = rt.Name;
                name[1] = "@p_PRICE"; value[1] = rt.Price;
                name[2] = "@p_DEPOSIT"; value[2] = rt.Deposit;
                name[3] = "@p_NOTE"; value[3] = rt.Note;

                return this.ExcuteStoreProcedure("ROOMTYPE_Ins", name, value);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return null;
        }
Example #5
0
 public bool updateRoomType(RoomType rt)
 {
     return roomTypeDAT.updateRoomType(rt);
 }
Example #6
0
 public DataTable searchRoomType(RoomType rt)
 {
     return roomTypeDAT.searchRoomType(rt);
 }
Example #7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtId.Text == string.Empty)
            {
                MessageBox.Show("You don't choose a room type to edit!", "Infomations", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                RoomType rt = new RoomType()
                {
                    Id = txtId.Text,
                    Name = txtName.Text,
                    Price = decimal.Parse(txtPrice.Text.Trim()),
                    Deposit = decimal.Parse(txtDeposit.Text.Trim()),
                    Note = txtNote.Text
                };

                RoomTypeEdit roomTypeEdit = new RoomTypeEdit(rt);
                roomTypeEdit.EditCompletedHandler += FormRoomTypeEdit_Completed;
                roomTypeEdit.ShowDialog();
            }
        }
Example #8
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (btnSearch.Text == "Reset")
            {
                this.resetUI();
                this.changeModeEditUI(true);
            }
            else
            {
                RoomType rt = new RoomType()
                {
                    Id = txtId.Text.Trim(),
                    Name = txtName.Text.Trim(),
                    Price = decimal.Parse(txtPrice.Text.Trim() == "" ? "0" : txtPrice.Text.Trim()),
                    Deposit = decimal.Parse(txtDeposit.Text.Trim() == "" ? "0" : txtDeposit.Text.Trim()),
                    Note = txtNote.Text.Trim()
                };

                this.dgvRoomType.DataSource = roomTypeBLT.searchRoomType(rt);
            }
        }
        public DataTable searchRoomType(RoomType rt)
        {
            try
            {
                string[] names = new string[6];
                object[] values = new object[6];

                names[0] = "@p_ID"; values[0] = rt.Id;
                names[1] = "@p_NAME"; values[1] = rt.Name;
                names[2] = "@p_PRICE"; values[2] = rt.Price;
                names[3] = "@p_DEPOSIT"; values[3] = rt.Deposit;
                names[4] = "@p_NOTE"; values[4] = rt.Note;
                names[5] = "@p_TOP"; values[5] = 0;

                return this.ExcuteStoreProcedure("ROOMTYPE_Search", names, values);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return null;
        }
 public bool updateRoomType(RoomType rt)
 {
     try
     {
         string sql = "Update roomtype set name = N'" + rt.Name + "', price = " + rt.Price.ToString().Replace(',', '.') + ",  deposit = " + rt.Deposit.ToString().Replace(',', '.') + ",  note = N'" + rt.Note + "' where id = '" + rt.Id.Trim() + "'";
         int result = this.ExecuteNonQuery(sql);
         if (result != 0)
         {
             return true;
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine("Message = {1}", ex.Message);
     }
     return false;
 }