private void buttonUpdateLine_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxLineId.Text)) { MessageBox.Show("Molimo odaberite liniju za izmjenu"); return; } Linije line = new Linije(); line.Id = Convert.ToInt32(textBoxLineId.Text); line.PolazakId = Convert.ToInt32(comboBoxStartLine.SelectedValue); usp_Get_All_Cities_Result destination = comboBoxDestinationLine.SelectedValue as usp_Get_All_Cities_Result; line.DestinacijaId = destination.Id; line.Naziv = comboBoxStartLine.Text + "-" + comboBoxDestinationLine.Text; line.PrevoznikId = Convert.ToInt32(comboBoxTravelers.SelectedValue); line.TipLinije = comboBoxTypeLine.Text; line.vrijemePolaska = dateTimePickerLine.Text; HttpResponseMessage response = HttpClientRequest.PostResult("/Relation/EditRelation", line); if (response.IsSuccessStatusCode) { MessageBox.Show("Uspjesno izmjenjena linija"); this.RelationForm_Load(sender, e); } }
private void buttonAddLine_Click(object sender, EventArgs e) { //Add new line Linije line = new Linije(); line.PolazakId = Convert.ToInt32(comboBoxStartLine.SelectedValue); usp_Get_All_Cities_Result destination = comboBoxDestinationLine.SelectedValue as usp_Get_All_Cities_Result; line.DestinacijaId = destination.Id; line.Naziv = comboBoxStartLine.Text + "-" + comboBoxDestinationLine.Text; line.PrevoznikId = Convert.ToInt32(comboBoxTravelers.SelectedValue); line.TipLinije = comboBoxTypeLine.Text; line.vrijemePolaska = dateTimePickerLine.Text; HttpResponseMessage response = HttpClientRequest.PostResult("/Relation/AddRelation", line); if (response.IsSuccessStatusCode) { MessageBox.Show("Uspjesno dodana linija"); this.RelationForm_Load(sender, e); } }
private void dataGridViewRelations_CellClick(object sender, DataGridViewCellEventArgs e) { //Initialize textboxes with cell clicked. string nameOfLine = dataGridViewRelations.Rows[e.RowIndex].Cells["Naziv_linije"].Value.ToString(); int hyphenIndex = nameOfLine.IndexOf("-"); comboBoxStartLine.Text = nameOfLine.Substring(0, hyphenIndex); comboBoxDestinationLine.Text = nameOfLine.Substring(hyphenIndex + 1, nameOfLine.Length - 1 - hyphenIndex); comboBoxTravelers.Text = dataGridViewRelations.Rows[e.RowIndex].Cells["Prevoznik"].Value.ToString(); comboBoxTypeLine.Text = dataGridViewRelations.Rows[e.RowIndex].Cells["Tip_linije"].Value.ToString(); dateTimePickerLine.Text = dataGridViewRelations.Rows[e.RowIndex].Cells["Vrijeme_polaska"].Value.ToString(); if (e.ColumnIndex == dataGridViewRelations.Columns["Neaktivna-aktivna"].Index) { //Make relation not active. HttpResponseMessage response = HttpClientRequest.PostResult("/Relation/MakeRelationUnActive/id", dataGridViewRelations.Rows[e.RowIndex].Cells["Id"].Value); if (response.IsSuccessStatusCode) { MessageBox.Show("Linija je neaktivna"); } } textBoxLineId.Text = dataGridViewRelations.Rows[e.RowIndex].Cells["Id"].Value.ToString(); }