private void txtConsulta_TextChanged(object sender, EventArgs e) { if (txtConsulta.Text.Contains(":")) { txtConsulta.Text = txtConsulta.Text.Replace(":", "@"); } if (txtConsulta.Text.Contains("@")) { var consulta = txtConsulta.Text.Trim(); var possicoes = txtConsulta.Text.AllIndexesOf("@"); _parametros = new BindingList<DadosStoredProceduresParameters>(); foreach (var posicao in possicoes) { var nomeParametro = consulta.Substring(posicao, RetornaPosicaoFinalNomeParametro((posicao + 1), consulta)); if (_parametros.Count(p => p.ParameterName == nomeParametro)==0) { _parametros.Add(new DadosStoredProceduresParameters { ParameterName = nomeParametro, DefineNull = true }); } } } CarregaGridViewParametros(); }
public static void StdGridRefresh(MainAppForm mainapp) { var query = Query.EQ("status", Properties.Settings.Default.StdFilterFlag); var stdresult = new BindingList<stdcolls>(stdcollection.Find(query).ToList()); mainapp.gridStudents.DataSource = stdresult; var count = Convert.ToInt16(stdresult.Count()); mainapp.ItemsCountStatusText.Caption = String.Format("{0} students count: {1}", Convert.ToString(Properties.Settings.Default.StdFilterFlag), Convert.ToString(count)); }
private void GumbReset_Click(object sender, EventArgs e) { datum_izdavanjaDateTimePicker.Value = DateTime.Now; izdavateljComboBox.SelectedIndex = -1; UpozorenjeIzdavatelj.Hide(); UpozorenjeOtpremnice.Hide(); int collectionSize = pridruzeneOtpremnice.Count(); if (collectionSize > 0) { do { collectionSize--; raspoloziveOtpremnice.Add(pridruzeneOtpremnice[collectionSize]); pridruzeneOtpremnice.RemoveAt(collectionSize); } while (collectionSize != 0); RefreshDGVs(); } }
private void AddThreadsToWorkingList() { if (bsWaiting.Count() > 0)// if the waiting list has any threads { ThreadWork threadWork = bsWaiting.First(x => x.Number == bsWaiting.Max(y => y.Number)); bsWaiting.Remove(threadWork); bsWorking.Add(threadWork); //the semaphore is sent as a parameter to the ThreadWork class. threadWork.Start(_s); } }
} //if any public double MaxCandidateValue() //add some gap to overcome round down { if (this.Type != ParameterType.Text) { List <double> numericalCandidateValues = GetNumericalCandidateValues(); return(numericalCandidateValues.Last() + (numericalCandidateValues.Last() - numericalCandidateValues[numericalCandidateValues.Count() - 2])); } else { return(_CandidateValues.Count()); } }
private void compareButton_Click(object sender, EventArgs e) { if (_shoppingCart.Count() == 0) { MessageBox.Show("לא נבחרו פריטים להשוואה"); return; } var result = _control.GetChainDetailses(_shoppingCart); ViewItems windowViewItems = new ViewItems(result, _shoppingCart); windowViewItems.ShowDialog(); }
private void button2_Click(object sender, EventArgs e) //Sorsoló gomb { var letszam = Students.Count(); var rnd = new Random(); var sorsolas = Enumerable.Range(0, letszam - 1).OrderBy(x => rnd.Next()).Take(letszam).ToList(); MessageBox.Show("Sorsolás megtörtént!"); for (int i = 0; i < letszam - 1; i++) { Students[i].Pair = sorsolas[i]; } }
public void execute(BindingList <NameMacro> tableNMacro, BindingList <Variable> tableV, BindingList <BodyMacro> tableMacro, BindingList <Instruction> tom) { if (Config.getInstance().macroMode) { tableMacro.Add(new BodyMacro() { Number = tableMacro.Count(), Body = $"{data.lable?.ToString()} {data.command.ToString()} {(data.args!=null ? data.args.get(0)?.ToString() : "")} {(data.args != null ? data.args.get(1)?.ToString() : "")}", }); return; } }
private void cmdGuardarPlan_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtPlan.Text)) { planes.Add(new Plan() { Habilitado = true, IdObraSocial = -1, IdPlan = planes.Count(), Nombre = txtPlan.Text }); } txtPlan.Text = string.Empty; }
private void actualizarEscalaPeriodo() { for (int i = 0; i < escalasPeriodos.Count(); i++) { switch (escalasPeriodos[i].escala.nombre) { case "A": escalasPeriodos[i].notaMax = Double.Parse(txtAMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtAMin.Text); escalasPeriodos[i].porcentajeCupos = Double.Parse(txtCuposA.Text); break; case "B": escalasPeriodos[i].notaMax = Double.Parse(txtBMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtBMin.Text); escalasPeriodos[i].porcentajeCupos = Double.Parse(txtCuposB.Text); break; case "C": escalasPeriodos[i].notaMax = Double.Parse(txtCMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtCMin.Text); escalasPeriodos[i].porcentajeCupos = Double.Parse(txtCuposC.Text); break; case "D": escalasPeriodos[i].notaMax = Double.Parse(txtDMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtDMin.Text); escalasPeriodos[i].porcentajeCupos = Double.Parse(txtCuposD.Text); break; case "E": escalasPeriodos[i].notaMax = Double.Parse(txtEMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtEMin.Text); escalasPeriodos[i].porcentajeCupos = Double.Parse(txtCuposE.Text); break; case "Alto": escalasPeriodos[i].notaMax = Double.Parse(txtAltoMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtAltoMin.Text); break; case "Medio": escalasPeriodos[i].notaMax = Double.Parse(txtMedioMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtMedioMin.Text); break; case "Bajo": escalasPeriodos[i].notaMax = Double.Parse(txtBajoMax.Text); escalasPeriodos[i].notaMin = Double.Parse(txtBajoMin.Text); break; } } }
private void ErrorSurfaceTypeChanged(object sender, EventArgs e) { rdoUniform.Enabled = rdoUniform.Checked ? true : Editable; valUniform.Enabled = Editable && rdoUniform.Checked; rdoAssociated.Enabled = rdoAssociated.Checked ? true : Editable && AssociatedSurfaces.Count() > 0; cboAssociated.Enabled = Editable && rdoAssociated.Checked; if (!rdoAssociated.Checked) { cboAssociated.SelectedIndex = -1; } rdoFIS.Enabled = rdoFIS.Checked ? true : Editable && AssociatedSurfaces.Count() > 1; cboFIS.Enabled = rdoFIS.Checked && Editable; cmdFISProperties.Enabled = rdoFIS.Checked && cboFIS.SelectedItem is FISLibraryItem; grdFISInputs.Enabled = cboFIS.Enabled; if (!rdoFIS.Checked) { cboFIS.SelectedIndex = -1; } }
public void execute(BindingList <NameMacro> tableNMacro, BindingList <Variable> tableV, BindingList <BodyMacro> tableMacro, BindingList <Instruction> tom) { Config config = Config.getInstance(); if (config.stackIf.Count != 0) { throw new ArgumentException("Не все ветви IF имеют ENDIF "); } if (tableNMacro.ToList().Last().StartIndex != tableMacro.Count()) { tableNMacro.ToList().Last().EndIndex = tableMacro.Count() - 1; } else { tableNMacro.ToList().Last().StartIndex = -1; tableNMacro.ToList().Last().EndIndex = -1; } config.macroMode = false; config.closeLastMacro(); }
private void btnDescargaPDF_Click(object sender, EventArgs e) { try { int count = lista.Count(); int contaChek = lista.Count(q => q.Checked == false); if (contaChek == count) { MessageBox.Show("Seleccione un Registro", "Sistemas"); return; } using (FolderBrowserDialog FBD = new FolderBrowserDialog()) { if (FBD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string ruta = FBD.SelectedPath; foreach (var item in lista) { if (item.Checked == true) { if (item.extencion == ".pdf") { string RutaFile = ""; RutaFile = ruta + "\\" + item.descripcion_archi; System.IO.File.WriteAllBytes(RutaFile, item.Archivo_adjunto); } } } } } MessageBox.Show("PDF Descargados Exitosamente", "Sistemas"); } catch (Exception ex) { } }
private void btnDerechaç_Click(object sender, EventArgs e) { try { in_Producto_Info Item = (in_Producto_Info)gridViewProducto.GetFocusedRow();; if (Item != null) { if (ProductoXProveedor.Count(v => v.IdProducto == Item.IdProducto) != 0) { return; } ProductoXProveedor.Add(Item); in_producto_x_cp_proveedor_Info obj = new in_producto_x_cp_proveedor_Info(); obj.IdEmpresa_prod = param.IdEmpresa; obj.IdEmpresa_prov = param.IdEmpresa; obj.IdProducto = Item.IdProducto; obj.IdProveedor = Convert.ToDecimal(cmbProveedor.EditValue); obj.NomProducto_en_Proveedor = ""; ProducXProvee.Grabar_Producto_Proveedor(obj, param.IdEmpresa, Item.IdProducto, ref mensaje); Producto.Remove(Item); gridControlProducto.RefreshDataSource(); gridControlProductoXPRoveedor.RefreshDataSource(); } //int[] Rows = gridViewProducto.GetSelectedRows(); //foreach (var item in Rows) //{ // gridViewProducto.FocusedRowHandle = item; // in_Producto_Info Item = (in_Producto_Info)gridViewProducto.GetFocusedRow(); // if (Item != null) // { // ProductoXProveedor.Add(Item); // } //} //foreach (var item in Rows) //{ // //gridViewProducto.FocusedRowHandle = item; // in_Producto_Info Item = (in_Producto_Info)gridViewProducto.GetRow(item); // if (Item != null) // { // Producto.Remove(Item); // } //} } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); } }
//<kha mới thêm 10/11/2019> private void PreviewFile_Click(object sender, RoutedEventArgs e) { List <string> newname = nameFile; //NewName = nameFile; for (int i = 0; i < ListFile.Count(); i++) { //string name1 = ListFile[i].Name; for (int j = 0; j < addedList.Count(); j++) { ListFile[i].newName = addedList[j].Operate(newname[i]); newname[i] = addedList[j].Operate(newname[i]); if (!findPoint(ListFile[i].newName)) { ListFile[i].newName += File[i].Extension.ToString(); } } } CheckLoopName(ListFile); CheckError(ListFile); }
private void button_New_Click(object sender, EventArgs e) { List_of_what_is_Mapped.Add(new Mapped { Receipt_Name = textBox_Receipt_name.Text, AutoTask_Name = textBox_AT_name.Text }); dataGridView1.DataSource = null;////nblIAM RESET DATASOUCE!!!!!!! var source = List_of_what_is_Mapped; bool isUnique = List_of_what_is_Mapped.Distinct().Count() == List_of_what_is_Mapped.Count(); if (isUnique == false) { MessageBox.Show("Error Duplictes"); } dataGridView1.DataSource = source; DataGridViewColumn column = dataGridView1.Columns[0]; column.Width = 430; DataGridViewColumn columns = dataGridView1.Columns[1]; columns.Width = 430; dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1; dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true; using (StreamWriter sw = new StreamWriter(@"Mapping_dgv_Entries.txt")) { foreach (Mapped item in List_of_what_is_Mapped) { sw.WriteLine(item.Receipt_Name + "," + item.AutoTask_Name ); } } Logwriter.writelog("#NEW MAPPING:Time,>>>>>Item Updated:Receipt Name, AT Name<<<<<"); Logwriter.writelog("NEW MAPPING:" + current_timestamp + "," + ">>>>>" + textBox_Receipt_name.Text + "," + textBox_AT_name.Text); }
private void Devices_ListChanged(object sender, ListChangedEventArgs e) { Device dev = null; int devsNum = Devices.Count();//поличество подключений после изменения if (e.NewIndex != devsNum) { dev = Devices[e.NewIndex];//объект с которым производились манипуляции } switch (e.ListChangedType) { case ListChangedType.ItemAdded: //Add item here. MessageBox.Show("Device Added"); dev.Registers.ListChanged += new ListChangedEventHandler(RegistersListChanged); //запуск события Создания для других подписчиков dev.OnCreate(); break; case ListChangedType.ItemChanged: //Change node associated with this item MessageBox.Show("State changed"); break; case ListChangedType.ItemMoved: //Parent changed. MessageBox.Show("ItemMoved"); break; case ListChangedType.ItemDeleted: MessageBox.Show("ItemDeleted"); break; case ListChangedType.Reset: //This reset all data and control need to refill all data. MessageBox.Show("Reset"); break; } }
public void setView(int PageNow) { int Key = (PageNow - 1) * cfg.CountView; var p = f.Skip(Key).Take(cfg.CountView); var l = new List <Food>(p); var g = new BindingList <Food>(l); foodshow.Clear(); for (int i = 0; i < g.Count(); i++) { foodshow.Add(g[i]); } }
public static void agregarImportados(BindingList <Equipo> listaFiltrada, DataGridView DGV) { try { foreach (Equipo eq in listaFiltrada) { eq.EsPredet = false; ((BindingList <Equipo>)DGV.DataSource).Add(eq); } if (DGV.Rows.Count == listaFiltrada.Count()) //no había elementos antes { ((BindingList <Equipo>)DGV.DataSource).ElementAt(0).EsPredet = true; } MessageBox.Show("Se han agregado " + listaFiltrada.Count().ToString() + " equipos"); IO.writeObjectAsJson(file, DGV.DataSource); } catch (Exception) { MessageBox.Show("Ha ocurrido un error. No se han podido importar"); throw; } }
public void LoadPage() { cardBookRooms = new BindingList <CardBookRoom>(cardBookRoomViewModel.FindAll()); for (int i = cardBookRooms.Count() - 1; i >= 0; i--) { if (cardBookRooms[i].isDelete == true) { cardBookRooms.RemoveAt(i); } } RentListView.ItemsSource = cardBookRooms; }
private void button1_Click(object sender, EventArgs e) { listCE.Add(new CompteEpargne() { numero = listCE.Count() + 1, solde = Convert.ToDouble(tsolde.Value), dateOuverture = tdateOuverture.Value, nomcomplet = tnom.Text }); tsolde.Value = tsolde.Minimum; tdateOuverture.Value = tdateOuverture.MinDate; tnom.Text = string.Empty; }
private void ShouldUnselectLanguages(ProjectDetails selectedProject) { var selectedLanguagesFromProject = selectedProject.LanguagesForPoject.Where(n => n.Value).Select(n => n.Key).ToList(); var count = 0; foreach (var languageName in selectedLanguagesFromProject) { //unselect language for project in data source list selectedProject.LanguagesForPoject[languageName] = false; var projectsToBeExported = _projectsDataSource.Where(n => n.LanguagesForPoject.ContainsKey(languageName) && n.ShouldBeExported).ToList(); foreach (var project in projectsToBeExported) { var languageShouldBeExported = project.LanguagesForPoject[languageName]; if (languageShouldBeExported) { count++; } } //that means no other project has this language selected so we can uncheck the language ox if (count.Equals(0)) { var languageToBeDeleted = _languages.FirstOrDefault(l => l.LanguageName.Equals(languageName)); if (languageToBeDeleted != null) { _languages.Remove(languageToBeDeleted); } } } // if the are any projects selected clear language list if (_projectsDataSource.Count(p => p.ShouldBeExported).Equals(0)) { _languages.Clear(); } RefreshLanguageListbox(); }
public void execute(BindingList <NameMacro> tableNMacro, BindingList <Variable> tableV, BindingList <BodyMacro> tableMacro, BindingList <Instruction> tom) { string tempArg1Name = Utils.validArgKey.IsMatch(data.args.get(0)) ? data.args.get(0).Remove(4, data.args.get(0).Length - 4) : data.args.get(0); string tempArg2Name = null; if (data.args.Length > 1) { tempArg2Name = Utils.validArgKey.IsMatch(data.args.get(1)) ? data.args.get(1).Remove(4, data.args.get(1).Length - 4) : data.args.get(1); } if (tempArg1Name == tempArg2Name) { throw new ArgumentException($"Параметры не могут иметь одинаковых имен"); } if (tableNMacro.Any(i => i.Name == data.lable)) { throw new ArgumentException($"Имя макроса {data.lable} уже содердится в талбице макроопределений\n"); } else { string arg2 = null; if (data.args.Length == 2) { arg2 = data.args.get(1); } NameMacro nameMacro = new NameMacro() { Name = data.lable, StartIndex = tableMacro.Count(), EndIndex = -1, Arg1 = data.args.get(0), Arg2 = arg2, }; tableNMacro.Add(nameMacro); //string[] firstArgData = data.args.get(0)?.Split('='); //tableV.Add(new Variable() //{ // Name = Utils.GetUniquePrefix(firstArgData[0]), // Value = firstArgData[1], // Scope = Config.getInstance().stack.Peek(), //}); //string[] secondArgData = data.args.get(1)?.Split('='); //tableV.Add(new Variable() //{ // Name = Utils.GetUniquePrefix(secondArgData[0]), // Value = secondArgData[1], // Scope = Config.getInstance().stack.Peek(), //}); Config.getInstance().openMacro(this); } }
private bool get_Det() { try { if (BLst_det_info.Count() == 0) { MessageBox.Show("Debe agregar un Servicio a la Orden ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var Serv in BLst_det_info) { if (Serv.Cantidad == 0) { this.item = Lst_Producto_info.FirstOrDefault(q => q.IdProducto == Serv.IdProducto); MessageBox.Show("Debe ingresar la cantidad al servicio " + item.pr_descripcion, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (Serv.Costo == 0) { this.item = Lst_Producto_info.FirstOrDefault(q => q.IdProducto == Serv.IdProducto); MessageBox.Show("Debe ingresar el costo al servicio " + item.pr_descripcion, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } Sucursal_info = ucIn_Sucursal_Bodega1.get_sucursal(); Bodega_info = ucIn_Sucursal_Bodega1.get_bodega(); Proveedor_info = ucCp_Proveedor1.get_ProveedorInfo(); OS_Info.IdActivoFijo = ucaF_Activo_Fijo1.GetId_Activo_fijo(); OS_Info.IdBodega = Bodega_info == null ? 0 :Bodega_info.IdBodega; OS_Info.IdSucursal = Sucursal_info == null ? 0 : Sucursal_info.IdSucursal; OS_Info.IdProveedor = Proveedor_info == null ? 0 : Proveedor_info.IdProveedor; OS_Info.IdEmpresa = param.IdEmpresa; OS_Info.Num_Documento = txtNoDoc.Text.Trim(); OS_Info.Num_Fact = txtNoFact.Text.Trim(); OS_Info.IdCentroCosto = ucCon_CentroCosto_ctas_Movi1.Get_IdCentroCosto(); OS_Info.Fecha = deFecha.EditValue == null ? DateTime.Now : (DateTime)deFecha.EditValue; OS_Info.Observacion = txtObservacion.Text.Trim(); OS_Info.List_in_Orden_servicio_x_Activo_fijo_det = new List <in_Orden_servicio_x_Activo_fijo_det_Info>(BLst_det_info); OS_Info.Estado = "A"; return(true); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public BindingList <Orden> listarOrdenes() { BindingList <Orden> lista = new BindingList <Orden>(); String cadena = "server=50.62.209.188;" + "user=fpaz; password=123456; database=LP2;" + "port=3306"; MySqlConnection conn = new MySqlConnection(cadena); conn.Open(); MySqlCommand comando = new MySqlCommand(); comando.CommandText = "SELECT * FROM ORDEN"; comando.Connection = conn; MesaDA mesaDA = new MesaDA(); BindingList <Mesa> lstMesas = new BindingList <Mesa>(); lstMesas = mesaDA.listarMesas(); OrdenMenuDetalleDA detalleDA = new OrdenMenuDetalleDA(); BindingList <Orden_Menu_Detalle> lstDetalle = new BindingList <Orden_Menu_Detalle>(); lstDetalle = detalleDA.listarDetalleDeOrden(); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Orden o = new Orden(); o.Id = reader.GetInt32(0); int idMesa = reader.GetInt32(1); for (int i = 0; i < lstMesas.Count(); i++) { if (lstMesas.ElementAt(i).Id == o.Id) { o.Mesa = lstMesas.ElementAt(i); break; } } for (int i = 0; i < lstDetalle.Count(); i++) { if (lstDetalle.ElementAt(i).IdOrden == o.Id) { o.DetalleOrden.Add(lstDetalle.ElementAt(i)); } } o.Hora_orden = reader.GetDateTime(2); o.PreioTotal = reader.GetDouble(3); lista.Add(o); } conn.Close(); return(lista); }
private async void btn_retrieve_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(_client.Auth.ApiKey)) { MessageBox.Show("LastFm API does not have a valid api key!"); return; } string username = txt_username.Text; int months = (int)num_months.Value; int nextPage = 1; int totalPages = 0; const int count = 200; // 50 default; 200 max do { PageResponse <LastTrack> recent = await _client.User.GetRecentScrobbles( username, DateTimeOffset.Now.AddMonths(-1 * months), nextPage, count ); foreach (LastTrack recentTrack in recent) { if (_tracks.Count(track => track.TrackName == recentTrack.Name) == 0) { _tracks.Add(new Track { TrackName = recentTrack.Name, ArtistName = recentTrack.ArtistName, AlbumName = recentTrack.AlbumName, NoPlays = 1 }); } else { _tracks.First(track => track.TrackName == recentTrack.Name).NoPlays++; } } nextPage = recent.Page + 1; totalPages = recent.TotalPages; progressbar.Value = (int)Math.Round((double)(100 * recent.Page) / (recent.TotalPages)); } while (nextPage - 1 != totalPages); // Sort the backing list then reset binding in the binding list _backingTracks.Sort((x, y) => string.Compare(x.TrackName, y.TrackName, StringComparison.Ordinal)); _tracks.ResetBindings(); }
public void GetUsers() { if (users.Count > 0) { users.Clear(); } string stream = searchStreamBX.SelectedItem.ToString(); string status = searchStatusBX.SelectedItem.ToString(); List <string> searchSkills = new List <string>(); //noConsultantsFoundTBX.Text = status; for (int k = 0; k < searchSelectedSkills.Count(); k++) { searchSkills.Add(searchSelectedSkills[k].ToString()); } //noConsultantsFoundTBX.Text = success.Count().ToString(); users = service.SearchForConsultants(stream, status, searchSkills); //noConsultantsFoundTBX.Text = users.Count().ToString(); BindingList <string> searchUsers = new BindingList <string>(); for (int i = 0; i < users.Count(); i++) { searchUsers.Add(users[i].Name); } searchUsersLBX.DataSource = searchUsers; noConsultantsFoundTBX.Text = searchUsers.Count().ToString() + " consultant(s) found"; searchUsersLBX.Visible = true; //// Display profile of selected user //for (int j = 0; j < users.Count(); j++) //{ // if (searchUsersLBX.SelectedItem.ToString() == users[j].Name) // { // service.GetProfile(users[j].UserId); // nameTBX.Text = users[j].Name; // degreeTBX.Text = users[j].Degree; // modulesTBX.Text = users[j].Modules; // locationTBX.Text = users[j].Location; // statusTBX.Text = users[j].TStatus; // streamTBX.Text = users[j].Stream; // emailTBX.Text = users[j].Email; // searchConsultantSkillsLBX.DataSource = users[j].Skills; // profileGBX.Visible = true; // } //} }
private void DGV_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Home) { if (bs.Count > 0) { bs.CurrencyManager.Position = 0; } } if (e.KeyData == Keys.End) { if (bs.Count > 0) { bs.CurrencyManager.Position = bs.Count - 1; } } if (e.KeyData == Keys.Delete) { if (items.Count() > 1) { var item = (Detalle)bs.Current; items.Remove(item); } else { items.Clear(); items.Add(new Detalle()); } } if (e.KeyData == Keys.Down) { if (bs.CurrencyManager.Position == items.Count - 1) { var filaActual = bs.CurrencyManager.Position; DataGridViewRow row = DGV.Rows[filaActual]; DataGridViewCell codigoCta = row.Cells[DGV.Columns["codigo"].Index]; DataGridViewCell montoDebe = row.Cells[DGV.Columns["debe"].Index]; DataGridViewCell montoHaber = row.Cells[DGV.Columns["haber"].Index]; if (IsCtaOk(codigoCta) && IsMontoOk(montoDebe, montoHaber)) { var item = new Detalle(); items.Add(item); DGV.CurrentCell = DGV[0, filaActual + 1]; } } } }
public BindingList <Orden_Menu_Detalle> listarDetalleDeOrden() { BindingList <Orden_Menu_Detalle> lista = new BindingList <Orden_Menu_Detalle>(); String cadena = "server=50.62.209.188;" + "user=fpaz; password=123456; database=LP2;" + "port=3306"; MySqlConnection conn = new MySqlConnection(cadena); conn.Open(); MySqlCommand comando = new MySqlCommand(); comando.CommandText = "SELECT * FROM ORDEN_MENU_DETALLE"; comando.Connection = conn; MySqlDataReader reader = comando.ExecuteReader(); EntradaDA entradaDA = new EntradaDA(); BindingList <Entrada> lstEntradas = new BindingList <Entrada>(); lstEntradas = entradaDA.listarEntradas(); PlatoFondoDA platoFondoDA = new PlatoFondoDA(); BindingList <PlatoFondo> lstPlatosFondo = new BindingList <PlatoFondo>(); lstPlatosFondo = platoFondoDA.listarPlatoFondo(); while (reader.Read()) { Orden_Menu_Detalle detalle = new Orden_Menu_Detalle(); detalle.Id = reader.GetInt32(0); detalle.IdOrden = reader.GetInt32(1); for (int i = 0; i < lstEntradas.Count(); i++) { if (lstEntradas.ElementAt(i).Id == reader.GetInt32(2)) { detalle.Entrada = lstEntradas.ElementAt(i); break; } } for (int i = 0; i < lstPlatosFondo.Count(); i++) { if (lstPlatosFondo.ElementAt(i).Id == reader.GetInt32(3)) { detalle.PlatoFondo = lstPlatosFondo.ElementAt(i); break; } } lista.Add(detalle); } conn.Close(); return(lista); }
private void CheckProjectsList(object sender = null, EventArgs e = null) { foreach (DataGridViewRow row in projectListDataGridView.Rows) { if (row.Cells[1]?.Value != null) // source { string pathToCheck = Path.Combine(DestinationProjectFolderTextBox.Text ?? "", row.Cells[0].Value.ToString()); if (!File.Exists(pathToCheck)) { row.Cells[0].Style.ForeColor = Color.OrangeRed; row.Cells[0].Style.Font = new Font(projectListDataGridView.RowTemplate.DefaultCellStyle.Font, FontStyle.Bold); row.Cells[0].ToolTipText += "Source Project does not exist on disk."; } else { row.Cells[1].Style.ForeColor = row.Cells[0].Style.ForeColor; row.Cells[1].Style.Font = new Font(projectListDataGridView.RowTemplate.DefaultCellStyle.Font, FontStyle.Regular); row.Cells[0].ToolTipText = ""; } } if (row.Cells[1]?.Value != null) // destination { if (projectsList.Count(destination => destination.DestinationProjectName == row.Cells[1].Value.ToString()) > 1) { row.Cells[1].Style.BackColor = Color.BlanchedAlmond; row.Cells[1].ToolTipText = "Destination is listed more than once. "; } else { row.Cells[1].Style.BackColor = row.Cells[0].Style.BackColor; row.Cells[1].ToolTipText = ""; } string pathToCheck = Path.Combine(DestinationProjectFolderTextBox.Text ?? "", row.Cells[1].Value.ToString()); if (File.Exists(pathToCheck)) { row.Cells[1].Style.ForeColor = Color.OrangeRed; row.Cells[1].Style.Font = new Font(projectListDataGridView.RowTemplate.DefaultCellStyle.Font, FontStyle.Bold); row.Cells[1].ToolTipText += "Destination Project already exists on disk."; } else { row.Cells[1].Style.ForeColor = row.Cells[0].Style.ForeColor; row.Cells[1].Style.Font = new Font(projectListDataGridView.RowTemplate.DefaultCellStyle.Font, FontStyle.Regular); } } } projectListDataGridView.Refresh(); }
public void GrabarDB() { try { string msg = ""; getInfo(); Lista_grabar = new List <ro_Config_Param_contable_Info>(); foreach (var item in lista_conf_sueldo_x_pagar)// detalle sueldo x pagar { Lista_grabar.Add(item); } foreach (var item in lista_conf_Provisiones)// detalle de procisines { Lista_grabar.Add(item); } foreach (var item in lista_sueldo) { item.IdEmpresa = param.IdEmpresa; if (item.Observacion == null) { item.Observacion = " "; } } if (Bus_ParamContable.GrabarParametrosContables(Lista_grabar, ref msg)) { if (oRo_Parametros_Bus.GrabarBD(info_parametro, ref MensajeError)) { if (lista_sueldo.Count() > 0) { bus_sueldo.Grabar(lista_sueldo.ToList()); } } } MessageBox.Show(Resources.msgConfirmaGrabarOk, Resources.msgTituloGrabar, MessageBoxButtons.OK, MessageBoxIcon.Information); CargarGrid(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); Log_Error_bus.Log_Error(ex.ToString()); } }
///////////////////////////importbutton///////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// private void button_Import_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; List_of_what_is_Mapped = new BindingList <Mapped>(); var FD = new System.Windows.Forms.OpenFileDialog(); if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileToOpen = FD.FileName; var watch = System.Diagnostics.Stopwatch.StartNew(); using (StreamReader sr = new StreamReader(fileToOpen)) { string line; while ((line = sr.ReadLine()) != null) { string[] wholeLine = line.Split(','); if (wholeLine.Length > 1) { List_of_what_is_Mapped.Add(new Mapped() { Receipt_Name = wholeLine[0], AutoTask_Name = wholeLine[1] }); } } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; int count = List_of_what_is_Mapped.Count(); Logwriter.writelog("#MAPPING IMPORT CSV:Time,Filename,Time lapsed,Count"); Logwriter.writelog("MAPPING IMPORT CSV:" + current_timestamp + "," + FD.FileName + "," + elapsedMs.ToString() + "," + count.ToString()); } var source1 = List_of_what_is_Mapped; dataGridView1.DataSource = source1; DataGridViewColumn column = dataGridView1.Columns[0]; column.Width = 430; DataGridViewColumn columns = dataGridView1.Columns[1]; columns.Width = 430; } using (StreamWriter sw = new StreamWriter(@"Mapping_dgv_Entries.txt")) { foreach (Mapped item in List_of_what_is_Mapped) { sw.WriteLine(item.Receipt_Name + "," + item.AutoTask_Name ); } } }
public void Execute() { BindingList<Part> parts = new BindingList<Part>(); var query = session.CreateSQLQuery(PartQuery.BuildSql(viewModel.Types, viewModel.Number, viewModel.Activity)) .SetResultTransformer(PartQuery.Transformer); var qparts = query.List<Part>(); foreach(var item in qparts) { parts.Add(item); } viewModel.Parts = parts; viewModel.Amount = parts.Count(); RefreshVisualStateEvent(); }
public static void StdGridRefresh(MainAppForm mainapp) { //if (mainapp.bandedStudentsGridView.RowCount > 0) //{ var query = Query.EQ("status", Properties.Settings.Default.StdFilterFlag); BindingList<stdcolls> stdresult = new BindingList<stdcolls>(stdcollection.Find(query).ToList()); mainapp.gridStudents.DataSource = stdresult; int count = Convert.ToInt16(stdresult.Count()); mainapp.ItemsCountStatusText.Caption = Convert.ToString(Properties.Settings.Default.StdFilterFlag) + " students count: " + Convert.ToString(count); //} //else //{ // int count = 0; // mainapp.ItemsCountStatusText.Caption = Convert.ToString(Properties.Settings.Default.StdFilterFlag) + " students count: " + Convert.ToString(count); //} }
public static void GroupGridRefresh(MainAppForm mainapp) { var query = Query.EQ("status", Properties.Settings.Default.GroupFilterFlag); var groupresult = new BindingList<groupcolls>(gebase.GetCollection<groupcolls>("groups").Find(query).ToList()); mainapp.gridGroup.DataSource = groupresult; var count = Convert.ToInt16(groupresult.Count()); mainapp.ItemsCountStatusText.Caption = String.Format("{0} groups count: {1}", Convert.ToString(Properties.Settings.Default.GroupFilterFlag), Convert.ToString(count)); mainapp.bandedGroupGridView.GroupPanelText = Convert.ToString(Properties.Settings.Default.GroupFilterFlag) + " groups list"; }
public string LoadDiagnosis(string code, BindingList<DiagnosisForGrid> diagnosisGrids) { if (diagnosisGrids.Count<DiagnosisForGrid>(diagnosis => diagnosis.Code == code) < 2) { return string.Empty; } else { return "Diagnosis is exist already!"; } }
public string LoadDefaultEntities(string code, BindingList<TestForGrid> testGrids, BindingList<SpecimenForGrid> specimenGrids, BindingList<TubeForGrid> tubeGrids) { if (testGrids.Count<TestForGrid>(test => test.Code == code) < 2) { var test = new TestServiceClient().GetTestByCode(code); var specimenForGrid = new SpecimenForGrid() { Code = test.DefaultSpecimen.Code }; specimenGrids.Add(specimenForGrid); LoadDefaultTube(test.DefaultSpecimen.Code, tubeGrids); return string.Empty; } else { return "Test is exist already!"; } }
public FrameworkElementFactory CreateRemoveSensorButtonTemplate(PlantsArea area, BindingList<DataGridSensorView> dataGridSensorViews, BindingList<DataGridServiceScheduleView> dataGridServiceScheduleViews, Func<PlantsArea, Sensor, ServiceSchedule, bool> removeSensor) { FrameworkElementFactory buttonTemplate = new FrameworkElementFactory(typeof (Button)); buttonTemplate.SetValue(ContentControl.ContentProperty, "X"); buttonTemplate.AddHandler( ButtonBase.ClickEvent, new RoutedEventHandler((o, e) => { DataGridSensorView dataGridSensorView = ((FrameworkElement) o).DataContext as DataGridSensorView; if (dataGridSensorView != null) { if (dataGridSensorViews.Count(s => s.Measurable == dataGridSensorView.Measurable) == 0) { MessageBox.Show( $"'{dataGridSensorView.Measurable}': sensor with such measurable does not exist"); return; } ServiceState serviceState = area.PlantServicesStates.ServicesStates.SingleOrDefault( state => state.IsFor(dataGridSensorView.Measurable)); if (serviceState != null) { DataGridServiceScheduleView dataGridServiceScheduleView = dataGridServiceScheduleViews.SingleOrDefault( s => s.ServiceName == serviceState.ServiceName); ServiceSchedule serviceSchedule = area.ServicesSchedulesStates.ServicesSchedules.SingleOrDefault( schedule => schedule.ServiceName == serviceState.ServiceName); removeSensor(area, dataGridSensorView.Sensor, serviceSchedule); dataGridSensorViews.Remove(dataGridSensorView); dataGridServiceScheduleViews.Remove(dataGridServiceScheduleView); } } OnRefreshControls(); }) ); return buttonTemplate; }
public FrameworkElementFactory CreateSensorSaveButtonTemplate(PlantsArea area, BindingList<DataGridSensorView> dataGridSensorViews, BindingList<DataGridServiceScheduleView> dataGridServiceScheduleViews, Func<PlantsArea, Sensor, ServiceSchedule, bool> saveSensor) { FrameworkElementFactory buttonTemplate = new FrameworkElementFactory(typeof (Button)); buttonTemplate.SetValue(ContentControl.ContentProperty, "Save"); buttonTemplate.AddHandler( ButtonBase.ClickEvent, new RoutedEventHandler((o, e) => { DataGridSensorView dataGridSensorView = ((FrameworkElement) o).DataContext as DataGridSensorView; if (dataGridSensorView != null) { try { ServiceState serviceState; ServiceSchedule serviceSchedule; if (dataGridSensorView.Sensor != null) { if (!dataGridSensorView.Sensor.MeasurableParameter.HasValidParameters()) { throw new Exception(); } if (dataGridSensorView.MeasurableIsModified) { string oldMeasurable = dataGridSensorView.Sensor.MeasurableType; dataGridSensorView.Sensor.MeasurableParameter.MeasurableType = dataGridSensorView.Measurable; serviceState = dataGridSensorView.Sensor.PlantsArea .PlantServicesStates.GetServiceState(state => state.IsFor(oldMeasurable)); if (serviceState != null) { serviceSchedule = dataGridSensorView.Sensor.PlantsArea .ServicesSchedulesStates.GetServiceSchedule( schedule => schedule.IsFor(serviceState.ServiceName)); serviceState.ServiceName = dataGridSensorView.Measurable; if (serviceSchedule != null) { serviceSchedule.ServiceName = serviceState.ServiceName; } saveSensor(area, dataGridSensorView.Sensor, serviceSchedule); dataGridSensorView.MeasurableIsModified = false; dataGridSensorView.IsModified = false.ToString(); MessageBox.Show( $"Sensor with measurable '{dataGridSensorView.Measurable}' updated"); OnRefreshControls(); return; } } saveSensor(area, dataGridSensorView.Sensor, null); dataGridSensorView.IsModified = false.ToString(); MessageBox.Show($"'{dataGridSensorView.Measurable}': sensor data saved"); return; } if (dataGridSensorViews.Count(s => s.Measurable == dataGridSensorView.Measurable) != 1) { MessageBox.Show( $"Sensor with measurable '{dataGridSensorView.Measurable}' already exists"); return; } CustomParameter customParameter = new CustomParameter(Guid.NewGuid(), Convert.ToInt32(dataGridSensorView.Optimal), Convert.ToInt32(dataGridSensorView.Min), Convert.ToInt32(dataGridSensorView.Max), dataGridSensorView.Measurable); CustomSensor sensor = new CustomSensor(Guid.NewGuid(), area, TimeSpan.Parse(dataGridSensorView.Timeout), customParameter); dataGridSensorView.Sensor = sensor; serviceState = new ServiceState(sensor.MeasurableType, true); area.PlantServicesStates.AddServiceState(serviceState); serviceSchedule = new ServiceSchedule(Guid.NewGuid(), area.Id, serviceState.ServiceName, new TimeSpan(0, 0, 10), new TimeSpan(0, 1, 0), new List<MeasurableParameter> {sensor.MeasurableParameter}); area.ServicesSchedulesStates.AddServiceSchedule(serviceSchedule); dataGridServiceScheduleViews.Add(new DataGridServiceScheduleView(serviceSchedule)); saveSensor(area, sensor, serviceSchedule); dataGridSensorView.IsModified = false.ToString(); MessageBox.Show($"'{dataGridSensorView.Measurable}': sensor data saved"); OnRefreshControls(); } catch (Exception) { MessageBox.Show($"'{dataGridSensorView.Measurable}': wrong sensor data"); } } }) ); return buttonTemplate; }
public void GetUsers() { if (users.Count > 0) { users.Clear(); } string stream = searchStreamBX.SelectedItem.ToString(); string status = searchStatusBX.SelectedItem.ToString(); List<string> searchSkills = new List<string>(); //noConsultantsFoundTBX.Text = status; for (int k = 0; k < searchSelectedSkills.Count(); k++) { searchSkills.Add(searchSelectedSkills[k].ToString()); } //noConsultantsFoundTBX.Text = success.Count().ToString(); users = service.SearchForConsultants(stream, status, searchSkills); //noConsultantsFoundTBX.Text = users.Count().ToString(); BindingList<string> searchUsers = new BindingList<string>(); for (int i = 0; i < users.Count(); i++) { searchUsers.Add(users[i].Name); } searchUsersLBX.DataSource = searchUsers; noConsultantsFoundTBX.Text = searchUsers.Count().ToString() + " consultant(s) found"; searchUsersLBX.Visible = true; //// Display profile of selected user //for (int j = 0; j < users.Count(); j++) //{ // if (searchUsersLBX.SelectedItem.ToString() == users[j].Name) // { // service.GetProfile(users[j].UserId); // nameTBX.Text = users[j].Name; // degreeTBX.Text = users[j].Degree; // modulesTBX.Text = users[j].Modules; // locationTBX.Text = users[j].Location; // statusTBX.Text = users[j].TStatus; // streamTBX.Text = users[j].Stream; // emailTBX.Text = users[j].Email; // searchConsultantSkillsLBX.DataSource = users[j].Skills; // profileGBX.Visible = true; // } //} }
private BindingList<StockItem> UniqueStocks() { var ds = GetProductsDS(); if (ds == null) return null; BindingList<StockItem> newDs = new BindingList<StockItem>(); foreach (var item in ds) { var c = ds.Count(s => s.ProductCode == item.ProductCode); if (c == 1) { newDs.Add(item); continue; } if (newDs.Count(s => s.ProductCode == item.ProductCode) > 0) // uz existuje continue; item.Disp_Qty = c; // nastavime celkovy pocet item.Ord_Qty = c; // nastavime celkovy pocet newDs.Add(item); } return newDs; }