private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtId.Text == string.Empty)
            {
                MessageBox.Show("You don't choose a contract to " + btnEdit.Text + "!", "Infomations", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                int rowIndex = dgvContract.CurrentRow.Index;
                Contract ctr = new Contract()
                {
                    Id = txtId.Text.Trim(),
                    Begindate = dateTimePickerDateBegin.Text,
                    Customerid = txtCustomerId.Text.Trim(),
                    IsValid = bool.Parse(cmbContractStatus.SelectedValue.ToString()),
                    Note = txtNote.Text,
                    PriceRoom = decimal.Parse(txtPriceRoom.Text.Trim() == "" ? "0" : txtPriceRoom.Text.Trim()),
                    Roomid = (dgvContract.DataSource as DataTable).Rows[rowIndex].Field<string>("RoomId"),
                    Deposit = (dgvContract.DataSource as DataTable).Rows[rowIndex].Field<decimal>("Deposit"),
                    Enddate = (dgvContract.DataSource as DataTable).Rows[rowIndex].Field<DateTime>("Enddate").ToShortDateString(),
                    Setdate = (dgvContract.DataSource as DataTable).Rows[rowIndex].Field<DateTime>("Setdate").ToShortDateString()
                };

                ContractEdit contractEdit = new ContractEdit(ctr, txtCustomerName.Text.Trim(), (cmbRoom.SelectedValue == null) ? "" : (cmbRoom.SelectedItem as DataRowView).Row.Field<string>("Name").ToString(), btnEdit.Text == "Edit" ? true : false);
                if (btnEdit.Text != "Edit")
                    contractEdit.EditCompletedHandler += FormContractEdit_Completed;
                contractEdit.ShowDialog();
            }
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     ContractEdit contractEdit = new ContractEdit();
     contractEdit.EditCompletedHandler += FormContractEdit_Completed;
     contractEdit.ShowDialog();
 }