private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } // получаем выбранный файл string filename = openFileDialog1.FileName; // читаем файл в строку string fileText = File.ReadAllText(filename); List <string> tmp = fileText.Split('\n').ToList(); tmp.RemoveAt(tmp.Count - 1); data = new BindingSource(); tmp.ForEach(x => data.Add(new Data() { X = Convert.ToDouble(x.Split(' ')[0]), Y = Convert.ToDouble(x.Split(' ')[1]) })); data.ListChanged += new ListChangedEventHandler(DataValueChanged); Random rnd = new Random(); int lastKey = dataBindings.Keys.Last() + 1; color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); comboBox2.Items.Add(new ChartColor() { index = lastKey, color = color }); dataBindings.Add(lastKey, data); dataGridView1.DataSource = data; comboBox2.SelectedIndex = dataBindings.Last().Key - 1; label1.Text = "Table " + comboBox2.SelectedItem.ToString(); ChangeChartData(); MessageBox.Show("Файл загружен"); }
private void HandlerAdd() { if (!(bool)dataSender["dataState"]) { return; } Order order = new Order(); order.order_id = (int)dataSender["currentId"]; order.customer_id = (int?)dataSender["customId"]; order.staff_id = (int?)dataSender["staffId"]; order.used_mark = (short)dataSender["mark"]; List <OrderDetail> details = (List <OrderDetail>)dataSender["orderDetails"]; sellBuss.CheckOut(order, details); if (sellBuss.AddOrder(order)) { orderSource.Add(ConvertOrder(order)); if (sellBuss.AddOrderDetails(details)) { MessageBox.Show("thêm thành công"); } else { MessageBox.Show("thêm thất bại"); } return; } MessageBox.Show("thêm thất bại"); }
private void btnAddProduct_Click_1(object sender, EventArgs e) { try { _ProductName = Product_Name(txtProductName.Text); _Category = cbCategory.Text; _MfgDate = dtPickerMfgDate.Value.ToString("yyyy-MM-dd"); _ExpDate = dtPickerExpDate.Value.ToString("yyyy-MM-dd"); _Description = richTxtDescription.Text; _Quantity = Quantity(txtQuantity.Text); _SellPrice = SellingPrice(txtSellPrice.Text); showProductList.Add(new ProductClass(_ProductName, _Category, _MfgDate, _ExpDate, _SellPrice, _Quantity, _Description)); gridViewProductList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; gridViewProductList.DataSource = showProductList; } catch (NumberFormatException ex) { MessageBox.Show(ex.Message); } catch (StringFormatException ex) { MessageBox.Show(ex.Message); } catch (CurrencyFormatException ex) { MessageBox.Show(ex.Message); } }
private void symbolsComboBox_OnSelectionChanged(object sender, EventArgs e) { string symbol = (string)symbols_ComboBox.SelectedValue; if (string.IsNullOrEmpty(symbol)) { return; } BindingSource bidsBS = new BindingSource(); bidsBS.DataSource = typeof(DisplayOrder); foreach (MdOrder bid in mMdRepository.GetOrderbook(symbol).Bids()) { bidsBS.Add(new DisplayOrder(bid)); } bidDataGridView.DataSource = bidsBS; bidDataGridView.AutoGenerateColumns = true; bidDataGridView.AutoResizeColumns(); BindingSource asksBS = new BindingSource(); asksBS.DataSource = typeof(DisplayOrder); foreach (MdOrder ask in mMdRepository.GetOrderbook(symbol).Asks()) { asksBS.Add(new DisplayOrder(ask)); } askDataGridView.DataSource = asksBS; askDataGridView.AutoGenerateColumns = true; askDataGridView.AutoResizeColumns(); }
private void FillFiles(string[] filePaths, string folderName) { this.label1.Text = folderName; var counter = 1; for (int i = 0; i < _bindingSource.Count; i++) { if (((Row)_bindingSource[i]).Path == null) { _bindingSource.RemoveAt(i); } } foreach (var filePath in filePaths) { ProcessingLabel.Text = counter + " sur " + filePaths.Length; ProcessingLabel.Refresh(); var date = Metadata.GetDate(filePath); var newDate = Metadata.ExtractNewDate(filePath); _bindingSource.Add(new Row { Path = filePath, CurrentDate = date, ExpectedDate = newDate }); counter++; } this.dataGridView.DataSource = _bindingSource; this.status.Text = "Ready"; this.status.ForeColor = Color.Black; }
private void CheckBigDataset() { Random rnd = new Random(); string RandomPassword() { string[] RandomPasswords = new string[] { "1234", "abracadabra", "qwerty", "dragon" }; return(RandomPasswords[rnd.Next(0, RandomPasswords.Length - 1)]); } void AddSampleRecords() { ClientDataSet3.DataSource = typeof(SampleRecords); for (int i = 1; i <= 10000; i++) { ClientDataSet3.Add(new SampleRecords() { Name = "Abc", Height = 3.45, Address = "Some St.", Children = i, Password = RandomPassword() }); } } if (ClientDataSet3.Count == 0) { AddSampleRecords(); } }
void DataGridView1CellValueChanged(object sender, DataGridViewCellEventArgs e) { int rowIndex = dataGridView1.FirstDisplayedCell.RowIndex; stops = new List <Stop>(); foreach (DataGridViewRow row in dataGridView1.Rows) { Stop s = row.DataBoundItem as Stop; stops.Add(s); } Days = GroupToDays(stops); foreach (Day d in Days) { d.Calculate(); } BindingSource src = new BindingSource(); foreach (Day d in Days) { foreach (Stop s in d.Stops) { src.Add(s); } } dataGridView1.DataSource = src; dataGridView1.FirstDisplayedScrollingRowIndex = rowIndex; }
private void btnKaydet_Click(object sender, EventArgs e) { // Kaydet butonuna tıklandığında Kitap sınıfında kitap isimli bir nesne oluşuyor. // Bu nesnenin herbir özelliği Text kutularına yazılan değere eşitleniyor. var kitap = new Kitap { Id = sayac, KitapAdi = txtKitapAdi.Text, Yazar = txtYazar.Text, YayinEvi = txtYayinEvi.Text, Raf = txtRaf.Text, Tur = txtTur.Text }; //Aşağıda Kitap Adı, Yazarı ve Yayınevi boş olup olmadığı kontrol ediliyor. if (!string.IsNullOrEmpty(kitap.KitapAdi) && !string.IsNullOrEmpty(kitap.Yazar) && !string.IsNullOrEmpty(kitap.YayinEvi)) { bsKitaplar.Add(kitap); // 3 Alana ait text kutusu dolu ise yukarıda tanımlanan Kitap sınıfında bir elemanı bsKitaplar // bsKitaplar isimli BindingSource verisine kaydediliyor. // Sadece önemli 3 alanın boş olması ile yetindim. sayac++; // Id için değer artırımı yapılıyor. FormTemizle(); // Kayıt arkasından form temizleniyor. } }
public void load_dataGridView_Retailer() { Cursor.Current = Cursors.WaitCursor; BindingSource bindingsource = new BindingSource(); List <Database.DBRetailers> rec = Database.DBRetailers.GetData(); foreach (Database.DBRetailers data in rec) { bindingsource.Add(new Database.DBRetailers( data.Wallet_Id, data.Date, data.Fname, data.Lname, data.Balance, data.Frozen, data.Sponsor_Id, data.Province, data.City, data.Barangay, data.BlockStr, data.Birth_Date )); } this.dataGridView_Retailer.AutoGenerateColumns = false; this.dataGridView_Retailer.DataSource = bindingsource; this.dataGridView_Retailer.ClearSelection(); Cursor.Current = Cursors.Default; }
/// <summary> /// Вызывается при нажатии на кнопку "Добавить запись" в таблице "Расходы на обслуживание" /// </summary> private void BtnServiceAdd_Click(object sender, EventArgs e) { var name = tbServiceName.Text; var cost = tbServiceCost.Text; var date = DateTime.Now.ToString("dd.MM.yyyy"); if (!(name != "" & cost != "")) { return; } var isCollesion = _serviceCollection.Exists(s => s.Date == date & s.Title == name); if (!isCollesion) { ChangeFilterButtonState(btnFilters, false); _serviceSource.DataSource = _serviceCollection; var service = new Service(_metaInfo.ServiceNumber++, name, date, Convert.ToDouble(cost)); _serviceSource.Add(service); tbServiceName.Text = ""; tbServiceCost.Text = ""; } else { MessageBox.Show(Resources.ServiceAddErrorMessage, Resources.CaptionMessageBox); } }
/// <summary> /// Вызывается при нажатии на кнопку "Добавить запись" таблицы "Хоз.расходы" /// </summary> private void BtnHouseAdd_Click(object sender, EventArgs e) { if (tbHouseName.Text.Length <= 0 || tbHouseCount.Text.Length <= 0 || tbHouseCost.Text.Length <= 0) { return; } var name = tbHouseName.Text; var count = Convert.ToInt32(tbHouseCount.Text); var cost = Convert.ToInt32(tbHouseCost.Text); var date = DateTime.Now.ToString("dd.MM.yyyy"); if (count > 0 && cost > 0) { ChangeFilterButtonState(btnHouseFilter, false); _householdSource.DataSource = _householdsCollection; var household = new Household(_metaInfo.HouseholdNumber++, name, date, count, cost, count * cost); _householdSource.Add(household); tbHouseName.Text = ""; tbHouseCount.Text = ""; tbHouseCost.Text = ""; } else { MessageBox.Show(Resources.HouseholdAddFailMessage, Resources.CaptionMessageBox); } }
/// <summary> /// Вызывается при нажатии на кнопку "Добавить запись" в таблице "Жильцы" /// </summary> private void BtnPersonAdd_Click(object sender, EventArgs e) { var name = tb_fullname.Text; var flat = tb_flatNum.Text; var count = tb_resCount.Text; if (!(name != "" & flat != "" & count != "")) { return; } var isCollision = _personCollection.Exists(p => p.FlatNumber == Convert.ToInt32(tb_flatNum.Text)); if (!isCollision) { _personSource.DataSource = _personCollection; ChangeFilterButtonState(btnPersonFilter, false); var person = new Person(_metaInfo.PersonNumber++, tb_fullname.Text, Convert.ToInt32(tb_flatNum.Text), Convert.ToInt32(tb_resCount.Text)); _personSource.Add(person); tb_fullname.Text = ""; tb_flatNum.Text = ""; tb_resCount.Text = ""; } else { MessageBox.Show(Resources.PersonAddFailMessage, Resources.CaptionMessageBox); } }
private void TakePhoto() { if (isCameraRunning) { frame = new Mat(); capture.Read(frame); // Take snapshot of the current image generate by OpenCV in the Picture Box Bitmap snapshot = BitmapConverter.ToBitmap(frame); snapshot.RotateFlip(RotateFlipType.Rotate90FlipXY); if (pictureBox2.Image != null) { pictureBox2.Image.Dispose(); } pictureBox2.Image = snapshot; string name = string.Format(@"C:\2\{0}{1}.jpeg", textBox1.Text, i); snapshot.Save(name, ImageFormat.Jpeg); source.Add(new Page() { Num = i, FName = name }); i++; /*name = string.Format(@"C:\2\{0}.jpeg", Guid.NewGuid()); * snapshot.Save(name, ImageFormat.Jpeg);*/ } else { Console.WriteLine("Cannot take picture if the camera isn't capturing image!"); } }
private void btnSave_Click(object sender, EventArgs e) { btnSaveEnbaled(false); if (opration == OP_ADD) { HRJob job = new HRJob(); job.Id = txtId.Text; job.Name = txtName.Text; int ret = dao.Add(job); if (ret > 0) { jobListSource.Add(job); } } else if (opration == OP_UPDATE) { HRJob job = jobList[grid.CurrentRow.Index]; job.Name = txtName.Text; dao.Update(job); grid.Refresh(); } CleanData(); }
/// <summary> /// Sélection des catégories filtrant les contacts affiliés /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lbxCategorie_SelectedIndexChanged(object sender, EventArgs e) { bindingSource = new BindingSource(); grv_contacts.DataSource = null; grv_contacts.Rows.Clear(); List <Contact> contactChecked = null; if (lbxCategorie.CheckedItems.Count > 0) { contactChecked = new List <Contact>(); foreach (Categorie categorie in lbxCategorie.CheckedItems) { foreach (Contact contact in categorie.ListContact) { if (contactChecked.Contains(contact) == false) { contactChecked.Add(contact); } } } } else { contactChecked = Program.ListContact; } foreach (Contact contact in contactChecked) { bindingSource.Add(contact); } grv_contacts.DataSource = bindingSource; grv_contacts.Refresh(); }
private void btnEliminar_Click(object sender, EventArgs e) { cola.EliminarPasajeroBusqueda(Convert.ToInt32(txtCodigoRuta.Text)); bindingSource1 = cargarBindingSource(); if (bindingSource1.Count != 0) { gridInfo.DataSource = bindingSource1; gridInfo.Refresh(); } else { /* bindingSource1 = new BindingSource(); * gridInfo.DataSource = bindingSource1; * gridInfo.Refresh();*/ Cliente elemento = new Cliente(); bindingSource1.Add(elemento); gridInfo.DataSource = bindingSource1; gridInfo.Refresh(); this.gridInfo.CurrentCell = null; this.gridInfo.Rows[0].Visible = false; pnlDatosCliente.Visible = false; } pnlDatosCliente.Visible = false; pnlGrilla.Visible = true; }
private void Form1_Load(object sender, EventArgs e) { // Set the DataSource of BindingSource1 to the Part type. BindingSource1.DataSource = typeof(Part); // Bind the textboxes to the properties of the Part type, // enabling formatting. partNameBinding = textBox1.DataBindings.Add("Text", BindingSource1, "PartName", true); partNumberBinding = textBox2.DataBindings.Add("Text", BindingSource1, "PartNumber", true); //Bind the textbox to the PartPrice value with currency formatting. textBox3.DataBindings.Add("Text", BindingSource1, "PartPrice", true, DataSourceUpdateMode.OnPropertyChanged, 0, "C"); // Handle the BindingComplete event for BindingSource1 and // the partNameBinding. partNumberBinding.BindingComplete += new BindingCompleteEventHandler(partNumberBinding_BindingComplete); partNameBinding.BindingComplete += new BindingCompleteEventHandler(partNameBinding_BindingComplete); // Add a new part to BindingSource1. BindingSource1.Add(new Part("Widget", 1234, 12.45)); }
private void buttonAddRobot_Click(object sender, EventArgs e) { if (!IsRobotInputValid()) { MessageBox.Show("Robot input is invalid. Make sure all fields are filled.", "Robot Input"); return; } if (AnyRobotWithSameName()) { MessageBox.Show("Robot with the same name has been defined. Please insert a different name.", "Robot Input"); return; } var commands = new List <RobotCommand>(); foreach (var obj in listBoxCommand.Items) { commands.Add((RobotCommand)obj); } var robotInput = new RobotInput { Name = textBoxName.Text, Location = new Point((int)numericUpDownPositionX.Value, (int)numericUpDownPositionY.Value), Heading = ConvertToHeading(comboBoxInitialHeading.SelectedItem.ToString()), RobotCommands = commands }; robotsBindingSource.Add(robotInput); }
/// <summary> /// Добавить нового сотрудника /// </summary> /// <returns></returns> private async Task InsertEmployee() { EmployeeModel employeeModel = GetDataFromForm(); Employee newEmployee = _modelMapper.Map <Employee>(employeeModel); string departmentName = employeeModel.Department; newEmployee.DepartmentId = _departmentDictionary[departmentName]; int id = await _dbEmployee.Insert(newEmployee); employeeModel.Id = id; _employeeDictionary.Add(id, employeeModel); if (_bindingSource == null) { _bindingSource = new BindingSource { DataSource = _employeeDictionary.Values }; EmployeeDataGrid.DataSource = _bindingSource; } else { _bindingSource.Add(employeeModel); } }
private void button1_Click(object sender, EventArgs e) { try { var kho = Convert.ToInt32(comboBoxKHO.SelectedValue.ToString()); var ncc = Convert.ToInt32(comboBoxNCC.SelectedValue.ToString()); var tien = Int32.Parse(textBoxTONGTIEN.Text); var ngay = dateTimePicker1.Value.Date; if (tien == 0) { MessageBox.Show("TIỀN TRẢ KHÔNG ĐƯỢC BẰNG 0"); return; } bs.Add(new TRA_NO_NCC() { MANCC = ncc, MAKHO = kho, TONG_TIEN = tien, NGAY_TRA = ngay, CREATED_AT = DateTime.Now }); bs.EndEdit(); bs.ResetBindings(false); DataInstance.Instance().DBContext().SaveChanges(); textBoxTONGTIEN.Text = "0"; comboBoxKHO.Select(); } catch (Exception ex) { MessageBox.Show("Dữ liệu nhập vào không phù hợp"); } }
public void Add(string s) { if (IsValid(s)) { bs.Add(s); } }
private void load_dataGridView_student() { try { Cursor.Current = Cursors.WaitCursor; BindingSource bindingsource = new BindingSource(); List <DBstudent> rec = DBstudent.GetData(); foreach (DBstudent data in rec) { bindingsource.Add(data); } this.dataGridView_student.Refresh(); this.dataGridView_student.AutoGenerateColumns = false; this.dataGridView_student.DataSource = bindingsource; this.dataGridView_student.ClearSelection(); Cursor.Current = Cursors.Default; } catch (Exception ex) { ex.ToString(); } }
private void OnAddButtonClick(object sender, EventArgs e) { _packageSources.Add(CreateNewPackageSource()); // auto-select the newly-added item PackageSourcesListBox.SelectedIndex = PackageSourcesListBox.Items.Count - 1; }
//Recibe como parámetro las ubicaciones del espectáculo a editar public FormAgregarUbicaciones(List <Ubicacion> _ubicaciones) { InitializeComponent(); dataGridViewUbicaciones.AutoGenerateColumns = false; dataGridViewUbicaciones.RowHeadersVisible = false; dataGridViewUbicaciones.AllowUserToResizeRows = false; this.Ubicaciones = _ubicaciones; comboBoxTipoUbicacion.SelectedIndex = 0; comboBoxFila.SelectedIndex = 0; this.Ubicaciones.ForEach(u => bindingSource.Add(u)); dataGridViewUbicaciones.DataSource = bindingSource; }
private void btnGhi_Click(object sender, EventArgs e) { using (WebClient wc = new WebClient()) { if (them == true) { wc.Encoding = Encoding.UTF8; wc.Headers[HttpRequestHeader.ContentType] = "application/json"; string diachi = "http://192.168.1.5/QLPhimService/NguoiDungService.svc/them"; var obj = new { MatKhau = txtPassword.Text, NguoiDungID = 0, Ten = txtTen.Text, NhomNguoiDungID = cbbNhomNguoiDung.SelectedValue }; string chuoijson = JsonConvert.SerializeObject(obj); string ketquatrave = wc.UploadString(diachi, "POST", chuoijson); MessageBox.Show(ketquatrave); bs.Add(obj); dataGridView1.DataSource = bs; bs.MoveLast(); them = false; } else { wc.Encoding = Encoding.UTF8; wc.Headers[HttpRequestHeader.ContentType] = "application/json"; string diachi = "http://localhost/QLPhimService/NguoiDungService.svc/sua"; NguoiDung current = bs.Current as NguoiDung; current.Ten = txtTen.Text; current.MatKhau = txtPassword.Text; current.NhomNguoiDungID = Convert.ToInt32((cbbNhomNguoiDung.SelectedValue)); string chuoijson = JsonConvert.SerializeObject(current); string ketquatrave = wc.UploadString(diachi, "PUT", chuoijson); bs.EndEdit(); MessageBox.Show(ketquatrave); } } }
private ErrorProvider EP = new ErrorProvider(); // default error provider #region SUB NEW | PROPERTIES // SUB NEW //------------------------------------------------------------------------------------------------------------ public frmContribuicaoCheque(ref objContribuicaoCheque cheque, Form formOrigem) { InitializeComponent(); if (cheque.IDContribuicao != null) { _cheque = GetCheque((long)cheque.IDContribuicao); } else { _cheque = cheque; } _formOrigem = formOrigem; GetBancosList(); // binding bind.DataSource = typeof(objContribuicaoCheque); bind.Add(_cheque); BindingCreator(); if (_cheque.IDContribuicao == null) { Sit = EnumFlagEstado.NovoRegistro; } else { Sit = EnumFlagEstado.RegistroSalvo; } // handlers _cheque.PropertyChanged += RegistroAlterado; HandlerKeyDownControl(this); }
public static void AddRange <T>(this BindingSource <T> bs, IEnumerable <T> items) { foreach (var item in items) { bs.Add(item); } }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { using (StreamReader reader = new StreamReader(openFileDialog1.FileName)) { source.Clear(); while (!reader.EndOfStream) { try { string[] temp = reader.ReadLine().Split(';'); source.Add(new Dog() { Name = temp[0], Owner = temp[1], Height = Double.Parse(temp[2]) }); } catch { MessageBox.Show("Не удалось прочитать файл"); } } } panel1.Visible = true; dataGridView1.DataSource = source; dataGridView1.Columns[0].HeaderText = "Кличка"; dataGridView1.Columns[1].HeaderText = "Владелец"; dataGridView1.Columns[2].HeaderText = "Размер в холке"; } }
private void ValidateSingleContactButton_Click(object sender, EventArgs e) { var contact = new Contact() { FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, PersonalEmail = PersonalEmailTextBox.Text, BusinessEmail = BusinessEmailTextBox.Text, Phone = PhoneTextBox.Text }; var validationResult = ValidationHelper.ValidateEntity(contact); if (!validationResult.HasError) { _bsContacts.Add(contact); if (_dataGridViewSizeDone) { return; } dataGridView1.ExpandColumns(); _dataGridViewSizeDone = true; } else { MessageBox.Show(validationResult.ErrorMessageList()); } }
/// <summary> /// Delete the selected rows from the list of approved origins /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteSelectedOrigins_Click(object sender, EventArgs e) { // Delete any selected rows foreach (DataGridViewRow row in selectedRows) { try { bindingSource.RemoveAt(row.Index); } catch { } } // Delete any remaining cells that were selected but were not parts of whole selected rows. // Some of these may have been removed when deleting whole rows above, so ignore any exceptions here foreach (DataGridViewCell cell in selectedCells) { try { bindingSource.RemoveAt(cell.RowIndex); } catch { } } // Add a single default row if all rows have been deleted if (bindingSource.Count == 0) { bindingSource.Add(new StringValue(SharedConstants.CORS_DEFAULT_PERMISSION.ToString())); } }