public static void createVedomost(Vedomost vedomost) { var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://loloman.pythonanywhere.com/api/vedomosts/"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = JsonConvert.SerializeObject(vedomost); streamWriter.Write(json); } Vedomost jsonDeserialized; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); jsonDeserialized = JsonConvert.DeserializeObject <Vedomost>(result); } /*foreach (VedomostLine line in vedomost.vedomost_lines) * { * var req = new Thread(new ParameterizedThreadStart(createVedomostLine)); * Tuple<Vedomost, VedomostLine> param = new Tuple<Vedomost, VedomostLine>(jsonDeserialized, line); * req.Start((object)param); * }*/ }
private void Menu_Click(object sender, RoutedEventArgs e) { MenuWindow window = new MenuWindow(); window.Show(); Vedomost.Close(); }
public async Task <IActionResult> Edit(int id, [Bind("VedomostId,EduYearId,StudentGroupId,SemestrNameId,DisciplineName")] Vedomost vedomost) { if (id != vedomost.VedomostId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vedomost); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VedomostExists(vedomost.VedomostId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EduYearId"] = new SelectList(_context.EduYears, "EduYearId", "EduYearName", vedomost.EduYearId); ViewData["SemestrNameId"] = new SelectList(_context.SemestrNames, "SemestrNameId", "SemestrNameName", vedomost.SemestrNameId); ViewData["StudentGroupId"] = new SelectList(_context.StudentGroups.Include(g => g.EduKurs), "StudentGroupId", "StudentGroupName", vedomost.StudentGroupId); return(View(vedomost)); }
private void Menu_Click(object sender, System.Windows.Input.MouseButtonEventArgs e) { MenuWindow window = new MenuWindow(); window.Show(); Vedomost.Close(); }
public Form1() { InitializeComponent(); ConstructionComboBox.SelectedIndex = 0; category = new Category(); vedomost = new Vedomost(PRabNumericUpDown.Value, PRaschNumericUpDown.Value, GroupOfProductComboBox.SelectedIndex, TMaxNumericUpDown.Value); //bs = new BindingSource(); sections = new BindingList<Section>(); //bs.DataSource = sections; comboBox1.DataSource = sections; comboBox1.DisplayMember = "NameOfSection"; comboBox1.ValueMember = "sections.ID"; cs = new BindingSource(); cs.DataSource = category.RIM; CategoryOfProductComboBox.DataSource = cs; group = new Group(); gs = new BindingSource(); gs.DataSource = group.GroupOfProduct; GroupOfProductComboBox.DataSource = gs; PProchMethodComboBox.SelectedIndex = 0; PPlotMethodComboBox.SelectedIndex = 0; PGermMethodComboBox.SelectedIndex = 0; DisplayVedomost(); }
private void RefreshVedomosts(object sender, FormClosedEventArgs e) { Vedomost newVedomost = ApiConnector.getVedomost(editingVedomost); inventarizationTable.Rows[indexEditingVedomost].Cells[0].Value = newVedomost.doc_num; inventarizationTable.Rows[indexEditingVedomost].Cells[1].Value = newVedomost.creation_date; vedomosts[vedomosts.IndexOf(editingVedomost)] = newVedomost; }
public static void editVedomost(Vedomost vedomost) { /*var oldVedomost = getVedomost(vedomost); * var oldCollection = oldVedomost.vedomost_lines; * var newCollection = vedomost.vedomost_lines; * * HashSet<VedomostLine> oldSet = new HashSet<VedomostLine>(oldCollection, new LineEqualityComparer()); * HashSet<VedomostLine> newSet = new HashSet<VedomostLine>(newCollection, new LineEqualityComparer()); * * newSet.IntersectWith(oldSet); * HashSet<VedomostLine> sameElements = new HashSet<VedomostLine>(newSet); * newSet = new HashSet<VedomostLine>(newCollection, new LineEqualityComparer()); * * newSet.ExceptWith(oldSet); * HashSet<VedomostLine> elementsToAdd = new HashSet<VedomostLine>(newSet); * newSet = new HashSet<VedomostLine>(newCollection, new LineEqualityComparer()); * * * oldSet.ExceptWith(newSet); * HashSet<VedomostLine> elementsToRemove = new HashSet<VedomostLine>(oldSet); * oldSet = new HashSet<VedomostLine>(oldCollection, new LineEqualityComparer()); * * foreach (VedomostLine line in sameElements) * editVedomostLine(line); * * foreach (VedomostLine line in elementsToAdd) * createVedomostLine(oldVedomost, line); * * foreach (VedomostLine line in elementsToRemove) * deleteVedomostLine(line);*/ var httpWebRequest = (HttpWebRequest)WebRequest.Create(vedomost.url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "PUT"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = JsonConvert.SerializeObject(vedomost); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); } }
private void saveChages(object depName) { Vedomost vedomost = new Vedomost(); var workshop = ApiConnector.getWorkshop((depName as string)); if (workshop == null) { MessageBox.Show("Цех с таким названием не найден", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //List<Detail> details = (List<Detail>)ApiConnector.getDetails(); // Возможно, можно удалить эту строку vedomost.creation_date = docCreateDate.Value.ToString("yyyy-MM-dd"); vedomost.doc_num = Convert.ToInt32(docNumberTextBox.Text); vedomost.workshop_pk = workshop.workshop_pk; vedomost.vedomost_lines = new List <VedomostLine>(); for (int i = 0; i < table.Rows.Count - 1; i++) { var vedomostLine = new VedomostLine(); try { vedomostLine.vedomost_line_pk = identificationTable[table.Rows[i]].vedomost_line_pk; vedomostLine.vedomost_pk = (Parent as EditingInventarization).vedomostLast.vedomost_pk; } catch { }; vedomostLine.detail_pk = details.Find(detail => detail.detail_name == table.Rows[i].Cells[0].Value.ToString()).detail_pk; vedomostLine.amount = Convert.ToInt32(table.Rows[i].Cells[2].Value); vedomost.vedomost_lines.Add(vedomostLine); } if (Parent is EditingInventarization) { vedomost.url = (Parent as EditingInventarization).vedomostLast.url; vedomost.vedomost_pk = (Parent as EditingInventarization).vedomostLast.vedomost_pk; ApiConnector.editVedomost(vedomost); MessageBox.Show("Ведомость была успешно изменена.", "Редактирование ведомости", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ApiConnector.createVedomost(vedomost); MessageBox.Show("Ведомость была успешно создана.", "Добавление ведомости", MessageBoxButtons.OK, MessageBoxIcon.Information); } progressBar1.Visible = false; if (!(Parent is EditingInventarization)) { table.Rows.Clear(); depTextBox.Text = ""; docNumberTextBox.Text = ""; docCreateDate.Value = DateTime.Now; } }
public static void deleteVedomost(Vedomost vedomost) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(vedomost.url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "DELETE"; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); } }
public async Task <IActionResult> Create([Bind("VedomostId,EduYearId,StudentGroupId,SemestrNameId,DisciplineName")] Vedomost vedomost) { if (ModelState.IsValid) { _context.Add(vedomost); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EduYearId"] = new SelectList(_context.EduYears, "EduYearId", "EduYearName", vedomost.EduYearId); ViewData["SemestrNameId"] = new SelectList(_context.SemestrNames, "SemestrNameId", "SemestrNameName", vedomost.SemestrNameId); ViewData["StudentGroupId"] = new SelectList(_context.StudentGroups.Include(g => g.EduKurs), "StudentGroupId", "StudentGroupName", vedomost.StudentGroupId); return(View(vedomost)); }
public static IEnumerable <VedomostLine> getVedomostLine(Vedomost vedomost) { IEnumerable <VedomostLine> jsonDeserialized; var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://loloman.pythonanywhere.com/api/vedomost-lines/?vedomost_pk=" + vedomost.vedomost_pk.ToString()); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "GET"; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { string jsonString = streamReader.ReadToEnd(); jsonDeserialized = JsonConvert.DeserializeObject <IEnumerable <VedomostLine> >(jsonString); } return(jsonDeserialized); }
public static Vedomost getVedomost(Vedomost vedomost) { Vedomost jsonDeserialized; var httpWebRequest = (HttpWebRequest)WebRequest.Create(vedomost.url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "GET"; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { string jsonString = streamReader.ReadToEnd(); jsonDeserialized = JsonConvert.DeserializeObject <Vedomost>(jsonString); } return(jsonDeserialized); }
public static void createVedomostLine(object param) { Tuple <Vedomost, VedomostLine> paramUnpacked = (Tuple <Vedomost, VedomostLine>)param; Vedomost vedomost = paramUnpacked.Item1; VedomostLine line = paramUnpacked.Item2; var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://loloman.pythonanywhere.com/api/vedomost-lines/"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; line.vedomost_pk = vedomost.vedomost_pk; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = JsonConvert.SerializeObject(line); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); } }
private void inventarizationTable_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { // удалить здесь DialogResult dialogResult = MessageBox.Show("Вы действительно хотите удалить ведомость №" + inventarizationTable.CurrentRow.Cells[0].Value.ToString() + "?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dialogResult == DialogResult.Yes) { int index = e.RowIndex; ApiConnector.deleteVedomost(vedomosts[index]); vedomosts.RemoveAt(index); AutoCompleteSourceForDocNum.RemoveAt(index); inventarizationTable.Rows.RemoveAt(index); MessageBox.Show("Ведомость была успешно удалена.", "Удаление ведомости", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (e.ColumnIndex == 2) { var identificationTable = new Dictionary <DataGridViewRow, VedomostLine>(); // открыть форму для редактирования инвентаризации Vedomost currVedomost = vedomosts.Find(vedomost => inventarizationTable.CurrentRow.Cells[0].Value.ToString() == vedomost.doc_num.ToString()); editingVedomost = currVedomost; indexEditingVedomost = e.RowIndex; EditingInventarization editingInventarizationForm = new EditingInventarization(currVedomost); InventarizationDocument inventarization = editingInventarizationForm.GetPanel; inventarization.GetDocCreateDate.Value = DateTime.Parse(currVedomost.creation_date); inventarization.GetDocNumberTextBox.Text = currVedomost.doc_num.ToString(); for (int i = 0; i < depNameComboBoxItems.Count; i++) { inventarization.GetDepComboBox.Items.Add(depNameComboBoxItems[i]); } string workshopName = ApiConnector.getWorkshop(currVedomost.workshop_pk).workshop_name; int index = depNameComboBoxItems.IndexOf(workshopName); inventarization.GetDepComboBox.SelectedIndex = index; DataGridView table = inventarization.GetTable; table.AllowUserToAddRows = false; inventarization.SetDetails = details; for (int i = 0; i < currVedomost.vedomost_lines.Count; i++) { table.Rows.Add(); table.Rows[i].Cells[1].Value = currVedomost.vedomost_lines[i].detail.cipher_detail; table.Rows[i].Cells[2].Value = currVedomost.vedomost_lines[i].amount; (table.Rows[i].Cells[0]).Value = currVedomost.vedomost_lines[i].detail.detail_name; identificationTable.Add(table.Rows[i], currVedomost.vedomost_lines[i]); } table.AllowUserToAddRows = true; inventarization.identificationTable = identificationTable; editingInventarizationForm.Show(); editingInventarizationForm.FormClosed += new FormClosedEventHandler(RefreshVedomosts); } }
public void StarVedomost() { notifierInfo.MethodName = "StarVedomost"; //NotifyObservers(); Vedomost?.Invoke(); }
public EditingInventarization(Vedomost currVedomost) { InitializeComponent(); vedomostLast = currVedomost; }