private void btnUpdateImport_Click(object sender, EventArgs e) { if (!MainClass.IsPasha()) { return; } if (MessageBox.Show("Обновить IsImported = true?", "Обновление", MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (DataGridViewRow dgvr in dgvAbiturients.SelectedRows) { string sId = dgvr.Cells["Id"].Value.ToString(); try { string query; query = string.Format("UPDATE [Application] SET IsImported = 1 WHERE Id = '{0}'", sId); _bdcInet.ExecuteQuery(query); } catch (Exception ex) { WinFormsServ.Error("Ошибка обновления данных" + ex.Message); goto Next; } Next :; } UpdateDataGrid(); } }
public void UpdatePersonData(int personBarc) { try { _bdcInet.ExecuteQuery("UPDATE Person SET IsImported = 1 WHERE Person.Barcode = " + personBarc); } catch (Exception exc) { WinFormsServ.Error(exc.Message); } }
private void btnLoad_Click(object sender, EventArgs e) { int?changeTp = ChangeTypeId; foreach (DataGridViewRow dgvr in dgvAbiturients.SelectedRows) { string code = dgvr.Cells["Barcode"].Value.ToString(); string perCode = dgvr.Cells["PersonBarcode"].Value.ToString(); try { int abitBarcode; int persBarcode; if (!int.TryParse(code, out abitBarcode)) { WinFormsServ.Error("Не распознан баркод!"); return; } if (abitBarcode == 0) { WinFormsServ.Error("Не распознан баркод!"); return; } if (!int.TryParse(perCode, out persBarcode)) { WinFormsServ.Error("Не распознан баркод!"); return; } if (persBarcode == 0) { WinFormsServ.Error("Не распознан баркод!"); return; } ChangeAbitClass chCl; string updateQuery = string.Empty; switch (changeTp) { // приоритеты case 1: { if (!MessageAttention()) { return; } chCl = lstAbits[abitBarcode]; using (PriemEntities context = new PriemEntities()) { Guid abitId = (from ab in context.extAbit where ab.Barcode == abitBarcode select ab.Id).FirstOrDefault(); double pr; if (!double.TryParse(chCl.Priority, out pr)) { break; } context.Abiturient_UpdatePriority(pr, abitId); break; } } // забрал доки в инете case 2: { if (!MessageAttention()) { return; } chCl = lstAbits[abitBarcode]; DataRow dr = _bdcInet.GetDataSet(string.Format("SELECT qAbiturient.BackDocDate FROM qAbiturient WHERE Barcode = {0}", abitBarcode)).Tables[0].Rows[0]; DateTime?backDate = dr.Field <DateTime?>("BackDocDate"); using (PriemEntities context = new PriemEntities()) { Guid abitId = (from ab in context.extAbit where ab.Barcode == abitBarcode select ab.Id).FirstOrDefault(); context.Abiturient_UpdateBackDoc(true, backDate, abitId); break; } } // забрал доки в нашей базе case 3: { if (!MessageAttention()) { return; } chCl = lstAbits[abitBarcode]; DataRow dr = _bdc.GetDataSet(string.Format("SELECT qAbiturient.BackDocDate FROM ed.qAbiturient WHERE Barcode = {0}", abitBarcode)).Tables[0].Rows[0]; DateTime?backDate = dr.Field <DateTime?>("BackDocDate"); updateQuery = string.Format("UPDATE qAbiturient SET Enabled = 0, DateOfDisable = '{1}' WHERE Barcode = {0}", abitBarcode, backDate == null ? "NULL" : backDate.Value.Date.ToShortDateString()); _bdcInet.ExecuteQuery(updateQuery); break; } // новые документы case 4: { new DocCard(persBarcode, abitBarcode, true, MainClass.dbType == PriemType.PriemForeigners).ShowDialog(); break; } } } catch (Exception ex) { WinFormsServ.Error("Ошибка обновления данных: " + code + ":" + ex.Message); goto Next; } Next :; } UpdateDataGrid(); }