private MultiSelectList GenerateMultiSelectListWithClient() { var allclientList = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()); List <Client> listC = new List <Client>() { new Client { client_id = 0, client_name = "Wybierz klienta" } }; if (!allclientList.Any()) { return(new MultiSelectList(listC.Select(x => new { key = x.client_id, value = x.client_name + " " + x.client_sname }), "key", "value")); } foreach (var i in allclientList) { listC.Add(i); } var result = new MultiSelectList(listC.Select(x => new { key = x.client_id, value = x.client_name + " " + x.client_sname }), "key", "value"); return(result); }
public static Client GetClientFullTextSearch(string searchText, out int clientId) { //error with non unique value in result selectClient = new SelectClient(); List <Client> result = new List <Client>(); result = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()); var client = result.Select(x => new { id = x.client_id, text = x.client_name + " " + x.client_sname + " " + x.client_phone }).Where(y => y.text.Contains(searchText)); if (client.Any() == false) { clientId = -1; return(new Client { client_id = 0, client_name = "brak", client_phone = "brak", client_sname = "brak", client_description = "brak" }); } var selectedClient = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()).Where(x => x.client_id == client.First().id).First(); clientId = client.First().id; return(selectedClient); }
public PartialViewResult AddClient(int?client_id) { ViewBag.clientList = GenerateMultiSelectListWithClient(); if (client_id != null) { var selectedClient = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Where(x => x.client_id == client_id).ToList(); return(PartialView(selectedClient)); } return(PartialView()); }
public int InsertObjectToDB(Client dataObject) { var insertClient = SInsertScripts.SqlLiteDBInsertClient(dataObject); string result = DBConnectAndExecute.ExecuteQuery(insertClient); if (result != string.Empty) { return(-1); } //this is not nessery because i passes in client_id in the parameter var lastAddedClient = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Where(x => x.client_id == dataObject.client_id).First(); return(lastAddedClient.client_id); }
private void CmbClientList_SelectedIndexChanged(object sender, EventArgs e) { if (ckbUpdateClient.Checked) { if (cmbClientList.SelectedIndex == 0) { FillClientControls(null, true); return; } var selectedClient = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Where(x => x.client_id == cmbClientList.SelectedIndex).First(); FillClientControls(selectedClient, false); } }
public static void SetDataToCmbClient(ComboBox cmbClientList) { selectClient = new SelectClient(); List <Client> clientList = new List <Client>(); clientList.Add(new Client { client_id = 0, client_name = "klient" }); foreach (var i in selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery())) { clientList.Add(new Client { client_id = i.client_id, client_name = i.client_name + " " + i.client_sname }); } cmbClientList.DataSource = clientList; cmbClientList.DisplayMember = "client_name"; cmbClientList.ValueMember = "client_id"; }
public void ShouldUpdateClient_when_IHaveHisId_returnTrue() { SqlLiteDB.SqlLiteDBCreateTableIFNotExist(); //search client var clientResult = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()).First(); //get his client_id int clientId = clientResult.client_id; //change his data Client changeClient = new Client() { client_name = clientResult.client_name, client_sname = clientResult.client_sname, client_phone = clientResult.client_phone, client_description = "zaktualizowny" }; bool result = updateClient.UpdateObject(changeClient, clientId); Assert.IsTrue(result); //check result }
public ActionResult AddReservation(Reservation reservation, string findClient) { int clientId = reservation.client_id; if (!String.IsNullOrEmpty(findClient)) { var clientList = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Select(x => new { desccription = x.client_name + " " + x.client_sname + " " + x.client_phone + " " + x.client_description, clientId = x.client_id }).ToList(); clientId = clientList.Where(x => x.desccription.Contains(findClient)).First().clientId; } insertObjectToDB.GetReservationIdAndInsertToDB(reservation.reservation_date, reservation.reservation_time.Hours, reservation.reservation_time.Minutes, clientId, reservation.services_id, reservation.employee_id); return(RedirectToAction("Index", "Reservation", new { visibleTrue = false })); }
public PartialViewResult UpdateClient(int?client_id, string findClient) { ViewBag.clientList = GenerateMultiSelectListWithClient(); if ((client_id != null) || (client_id == 0)) { return(PartialView(selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Where(x => x.client_id == client_id).First())); } if (!String.IsNullOrEmpty(findClient)) { var clientList = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Select(x => new { desccription = x.client_name + " " + x.client_sname + " " + x.client_phone + " " + x.client_description, clientId = x.client_id }).ToList(); return(PartialView(clientList.Where(x => x.desccription.Contains(findClient)).First())); } return(PartialView()); }
public List <VReservation> GetVReservations() { var clientsList = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()); var servicesList = selectServices.GetRowsForTable(SGetAllRowsFromSpecificTable.ServicesSelectAllRowsQuery()); var reservationList = selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery()); var employeeList = selectEmployee.GetRowsForTable(SGetAllRowsFromSpecificTable.EmployeeSelectAllRowsQuery()); var result = reservationList.Join(clientsList, x => x.client_id, y => y.client_id, (x, y) => new { clName = y.client_name, clSname = y.client_sname, clPhone = y.client_phone, clDesc = y.client_description, resId = x.reservation_id, resDate = x.reservation_date, resTime = x.reservation_time, serId = x.services_id, empID = x.employee_id, clId = y.client_id }) .Join(servicesList, x => x.serId, y => y.services_id, (x, y) => new { x.resId, x.resDate, x.resTime, x.clName, x.clSname, x.clPhone, x.clDesc, y.services_name, y.services_id, x.empID, x.clId }) .Join(employeeList, x => x.empID, y => y.employee_id, (x, y) => new { x.clName, x.clSname, x.clPhone, x.clDesc, x.resId, x.resDate, x.resTime, x.services_id, x.services_name, empName = y.employee_name, x.empID, x.clId }).Select(x => new VReservation { reservation_id = x.resId, reservation_date = x.resDate, reservation_time = x.resTime, client_name = x.clName, client_sname = x.clSname, client_phone = x.clPhone, client_description = x.clDesc, services_name = x.services_name, services_id = x.services_id, employee_name = x.empName, client_id = x.clId, employee_id = x.empID, client_data = x.clName + " " + x.clSname + " " + x.clPhone + " " + x.clDesc }).OrderByDescending(x => x.reservation_date.ToShortDateString()).ThenByDescending(y => y.reservation_time).ToList(); return(result); }
public bool UpdateObject(Client dataobjectForChange, int id) { var updateClient = SUpdateScripts.SqlLiteDBUpdateClient(dataobjectForChange, id); string result = DBConnectAndExecute.ExecuteQuery(updateClient); if (result != string.Empty) { return(false); } return(VerifyUpdateData(dataobjectForChange, selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery()) .Where(x => x.client_id == id).First())); }