private void modifyHotel() { if (dgHotel.SelectedCells.Count == 0) { MessageBox.Show(LangBase.GetString("NOT_SELECT_HOTEL")); return; } else { int rowIndex = dgHotel.SelectedCells[0].RowIndex; HotelDto hotel = hotels[rowIndex]; AddHotel modifyHotel = new AddHotel(hotel); if (isModify) { if (modifyHotel.ShowDialog() == DialogResult.OK) { modifyHotel.hotel.HouseID = hotel.HouseID; string str_result = WebCall.PostMethod <HotelDto>(WebCall.ModifyHotel, modifyHotel.hotel); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { hotel.HouseName = modifyHotel.hotel.HouseName; hotel.Fee = modifyHotel.hotel.Fee; hotel.AgentFee = modifyHotel.hotel.AgentFee; hotel.CoverPic = modifyHotel.hotel.CoverPic; hotel.Pics = modifyHotel.hotel.Pics; hotel.Description = modifyHotel.hotel.Description; hotel.Remark = modifyHotel.hotel.Remark; hotel.Location = modifyHotel.hotel.Location; hotel.RoomCount = modifyHotel.hotel.RoomCount; dgHotel.DataSource = null; dgHotel.DataSource = hotels; } else { ClientUtils.WarningCode(result.Message); } } } else { if (modifyHotel.ShowDialog() == DialogResult.OK) { hotels.RemoveAt(rowIndex); hotels.Add(modifyHotel.hotel); dgHotel.DataSource = null; dgHotel.DataSource = hotels; } } } }
private void btnAddHotel_Click(object sender, EventArgs e) { AddHotel addHotel = new AddHotel(); if (addHotel.ShowDialog() == DialogResult.OK) { if (isModify) { addHotel.hotel.SupplierID = supplier.SupplierID; string str_result = WebCall.PostMethod <HotelDto>(WebCall.AddHotel, addHotel.hotel); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { hotels.Add(addHotel.hotel); dgHotel.DataSource = null; dgHotel.DataSource = hotels; } else { ClientUtils.WarningCode(result.Message); } } else { hotels.Add(addHotel.hotel); dgHotel.DataSource = null; dgHotel.DataSource = hotels; } } }