private void comboBoxCity_SelectedIndexChanged(object sender, EventArgs e) { string city = comboBoxCity.Text; comboBoxEstateType.SelectedIndex = 0; dataGridViewEstates.Rows.Clear(); IQueryable <EstateObject> output = null; bool colCity = true; try { output = ClassGetContext.context.EstateObjects; if (city != "(нет)") { output = (from estate in ClassGetContext.context.EstateObjects where estate.city == city select estate); colCity = false; } FillTable(output.ToList()); ColumnVision(city: colCity); } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }
private void buttonClear_Click(object sender, EventArgs e) { textBoxCitySearch.Clear(); textBoxStreetSearch.Clear(); textBoxHouseSearch.Clear(); numApartSearch.Value = 0; try { FillTable(ClassGetContext.context.EstateObjects.ToList()); } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }
private void buttonChange_Click(object sender, EventArgs e) { if (AllValid()) { currAgent = ClassGetContext.context.Agents.Where(x => x.idAgent == currAgent.idAgent).FirstOrDefault(); currAgent.firstName = textBoxFirstN.Text; currAgent.middleName = textBoxMiddleN.Text; currAgent.lastName = textBoxLastN.Text; currAgent.dealShare = (int)numDealShare.Value; ClassGetContext.context.SaveChanges(); FillTable(); HidingTracks(); } else { FormMessage form = new FormMessage("Проверьте введенные данные", ChangePic.warning); form.ShowDialog(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (AllValid()) { currClient.firstName = textBoxFirstN.Text; currClient.middleName = textBoxMiddleN.Text; currClient.lastName = textBoxLastN.Text; currClient.email = textBoxMail.Text; currClient.phone = textBoxPhone.Text; ClassGetContext.context.Clients.Add(currClient); ClassGetContext.context.SaveChanges(); FillTable(); HidingTracks(); } else { FormMessage form = new FormMessage("Проверьте введенные данные", ChangePic.warning); form.ShowDialog(); } }
private void buttonSearch_Click(object sender, EventArgs e) { try { var result = (from estate in ClassGetContext.context.EstateObjects select estate).ToList(); result = result.Where(est => Levenchtein.Length(est.city, textBoxCitySearch.Text) <= 3 && Levenchtein.Length(est.street, textBoxStreetSearch.Text) <= 3 && Levenchtein.Length(est.house, textBoxHouseSearch.Text) <= 1 && Levenchtein.Length(est.addressNumber, numApartSearch.Value.ToString()) <= 1) .Select(es => es) .ToList(); FillTable(result); } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }
private void buttonDel_Click(object sender, EventArgs e) { try { var ctx = ClassGetContext.context; var isLock = (from estate in ctx.EstateObjects join sent in ctx.Sentences on estate.idEstate equals sent.idEstate where estate.idEstate == estateObject.idEstate select estate); if (isLock.Any()) { FormMessage form = new FormMessage("Эта недвижимость учавствует в Предложении", ChangePic.error); form.ShowDialog(); } else { var delet = ctx.EstateObjects.Where(es => es.idEstate == estateObject.idEstate).FirstOrDefault(); ctx.EstateObjects.Remove(delet); ctx.SaveChanges(); comboBoxEstateEdit.Text = ""; comboBoxEstateType.SelectedIndex = 0; using (var form = new FormMessage("Недвижимость удалена", ChangePic.success)) form.ShowDialog(); BoxesVision(false, false, false, false, false, false, false, false, false, false); FillTable(ctx.EstateObjects.ToList()); FillComboBox(); } } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }
private void buttonDel_Click(object sender, EventArgs e) { var ctx = ClassGetContext.context; var isLock = (from client in ctx.Clients join sentence in ctx.Sentences on client.idClient equals sentence.idClient where client.idClient == currClient.idClient select client); if (isLock.Any()) { FormMessage form = new FormMessage("Данный клиент не может быть удален, так как участвует в Предложении", ChangePic.error); form.ShowDialog(); } else { var del = ctx.Clients.Where(x => x.idClient == currClient.idClient).FirstOrDefault(); ctx.Clients.Remove(del); ctx.SaveChanges(); FillTable(); } HidingTracks(); }
private void buttonAdd_Click(object sender, EventArgs e) { try { int idEstate = estateObject.idEstate; var ctx = ClassGetContext.context; estateObject = new EstateObject { idEstate = idEstate, city = textBoxCity.Text, street = textBoxStreet.Text, house = textBoxHouse.Text, addressNumber = textBoxApart.Text, floor = Convert.ToInt32(string.IsNullOrEmpty(textBoxFloor.Text) ? "0" : textBoxFloor.Text), totalArea = numArea.Value, totalFloors = Convert.ToInt32(numTotalFloor.Value), rooms = Convert.ToInt32(numTotalRooms.Value), longitude = numLongit.Value, latitude = numLatit.Value, typeEstate = comboBoxEstateEdit.Text, }; ctx.EstateObjects.Add(estateObject); ctx.SaveChanges(); using (var form = new FormMessage("Недвижимость добавлена", ChangePic.success)) form.ShowDialog(); FillTable(ctx.EstateObjects.ToList()); BoxesVision(); } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }
private void buttonChange_Click(object sender, EventArgs e) { try { var ctx = ClassGetContext.context; var curEst = ctx.EstateObjects.Where(es => es.idEstate == estateObject.idEstate).FirstOrDefault(); curEst.city = textBoxCity.Text; curEst.street = textBoxStreet.Text; curEst.house = textBoxHouse.Text; curEst.addressNumber = textBoxApart.Text; curEst.floor = Convert.ToInt32(textBoxFloor.Text); curEst.totalArea = numArea.Value; curEst.totalFloors = Convert.ToInt32(numTotalFloor.Value); curEst.rooms = Convert.ToInt32(numTotalRooms.Value); curEst.longitude = numLongit.Value; curEst.latitude = numLatit.Value; curEst.typeEstate = comboBoxEstateEdit.Text; ctx.SaveChanges(); FillComboBox(); comboBoxEstateEdit.Text = ""; comboBoxEstateType.SelectedIndex = 0; using (var form = new FormMessage("Недвижимость изменена", ChangePic.success)) form.ShowDialog(); BoxesVision(false, false, false, false, false, false, false, false, false, false); FillTable(ctx.EstateObjects.ToList()); } catch { using (var form = new FormMessage("Что-то пошло не так...", ChangePic.error)) form.ShowDialog(); } }