void Sorting(RevisionCl rowL, int newEtap, int oldEtap) { try { if (revL != null) { if (revL.All(r => r.Etap != newEtap)) // чтобы не было дублирующих этапов { var removeRows = revL.Where(r => r.Etap == oldEtap).OrderByDescending(r => r).ToList(); int removeRowsCount = removeRows.Count(); if (removeRows != null) { foreach (var rem in removeRows) { revL.Remove(rem); } List <int> ind = new List <int>(); var devidedByRevicion = revL.GroupBy(g => g.Revision); if (devidedByRevicion != null && devidedByRevicion.Count() > 0) { foreach (var devR in devidedByRevicion) { var lastEt = devR.LastOrDefault(r => r.Etap <= newEtap); if (lastEt == null) { lastEt = devR.Last(); } ind.Add(revL.IndexOf(lastEt)); } } else { ind = Enumerable.Repeat(-1, removeRowsCount).ToList(); } if (ind != null && ind.Count == removeRowsCount) { int chet = ind.Count - 1; foreach (var rem in removeRows) { var rev = (rem as RevisionCl).Copy(); rev.Etap = newEtap; revL.Insert(ind[chet] + 1, new RevisionClWithEvent(rev)); chet -= 1; } } } } } } catch { throw; } }
private void CreateGraph3Data() { var dataList = new List <DataForGraph3>(); var groupedResults = results.GroupBy(x => x.ProcessPriority).Select(grp => grp.ToList()).ToList(); foreach (var grp in groupedResults) { int amountOfRes = 0; long allPauseTime = 0; foreach (var res in grp) { if (res.EndTime != 0) { amountOfRes++; allPauseTime += res.PauseTime; } } if (amountOfRes > 0) { long averagePauseTime = allPauseTime / amountOfRes; dataList.Add(new DataForGraph3() { averagePauseTime = averagePauseTime, priority = grp[0].ProcessPriority }); } } DataForGraph3.Serialize(dataList); }
private void timer1_Tick(object sender, EventArgs e) { try { foreach (var item in lista_emplados) { item.Info_marcaciones_x_empleado.es_Hora = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); gridControlAsistencia.RefreshDataSource(); } var line = lista_emplados.GroupBy(info => info.CodCatalogo) .Select(group => new { CodCatalogo = group.Key, cantidad = group.Count() }); gridControl_resumen.DataSource = line; gridControl_resumen.RefreshDataSource(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); Log_Error_bus.Log_Error(ex.ToString()); } }
public static List <ColumnChartData> ColumnChartPrepareData() { // Create new BindingList from users incomes var income = new BindingList <Model.Income>(Database.Users.First(item => item.Username == Database.Session.Username).Incomes); // Return incomes grouped by date, select only dates and summed amount return(income.GroupBy(x => x.Date) .Select(g => new ColumnChartData { Date = g.Key, Amount = g.Sum(x => x.Amount) }).ToList()); }
private void RefreshTimerTicked(object sender, EventArgs e) { foreach (var item in services) { item.Refresh(); } var titles = services.GroupBy(s => s.Status).Select(s => s.Key + ": " + s.Count()); Text = string.Join(", ", titles); }
public static List <ColumnChartData> ColumnChartPrepareData() { // Create new BindingList from users expenses var expenses = new BindingList <Model.Expense>(Database.Users.First(item => item.Username == Database.Session.Username).Expenses); // Return a list of expenses grouped by date return(expenses.GroupBy(x => x.Date) .Select(g => new ColumnChartData { Date = g.Key, Amount = g.Sum(x => x.Amount) }).ToList()); }
private void SetTitle() { if (services.Any()) { var titles = services.GroupBy(s => s.Status).Select(s => (string.IsNullOrWhiteSpace(s.Key) ? "Unknown" : s.Key) + ": " + s.Count()); Text = "Total: " + services.Count + ", " + string.Join(", ", titles); } else { Text = "Total: 0"; } }
public static List <PieChartData> PieChartPrepareData() { // Create new BindingList from users incomes var income = new BindingList <Model.Income>(Database.Users.First(item => item.Username == Database.Session.Username).Incomes); // Return incomes grouped by category, select only categories and the count of the incomes in the categories return(income .GroupBy(l => l.Category) .Select(cl => new PieChartData { Category = cl.First().Category, Amount = cl.Count(), }).ToList()); }
public bool ListHasDuplicatedRank(BindingList <Setting> list) { var duplicates = list.GroupBy(x => x.Rank).Where(item => item.Count() > 1); int count = 0; foreach (var duplicate in duplicates) { foreach (var item in duplicate) { count++; } } return(count > 0); }
public static List <PieChartData> PieChartPrepareData() { // Create new BindingList from users expenses var expenses = new BindingList <Model.Expense>(Database.Users.First(item => item.Username == Database.Session.Username).Expenses); // Return a list of expenses grouped by category return(expenses .GroupBy(l => l.Category) .Select(cl => new PieChartData { Category = cl.First().Category, Amount = cl.Count(), }).ToList()); }
private void btn_execute_Click(object sender, EventArgs e) { MainFormValues mfv = new MainFormValues(txt_existingPassword.Text, txt_password.Text, txt_targetFolder.Text, txt_outputFolderPath.Text); //TODO this will not work with grouping emails if (GroupBy) { int max = fileData.GroupBy(o => o.Site).Count(); progressBar1.Maximum = max; } else { progressBar1.Maximum = fileData.Count; } progressBar1.Minimum = 0; progressBar1.Step = 1; progressBar1.Value = 0; backgroundWorker1.RunWorkerAsync(mfv); btn_execute.Enabled = false; }
private void btnRimuoviDuplicati_Click(object sender, EventArgs e) { var gruppi = _elencoDestintari.GroupBy(x => x.Address.ToLower(), x => x); var gruppiDoppi = gruppi.Where(x => x.Count() > 1); if (!gruppiDoppi.Any()) { MessageBox.Show("Non ci sono duplicati."); } else { var msg = $"Ci sono in tutto {gruppiDoppi.Sum(x => x.Count()-1)} duplicati." + Environment.NewLine + "Procedere con l'eliminazione?"; var res = ConfirmBox.Execute(msg, "COnferma eliminazione duplicati"); if (res) { dataGridView1.SuspendLayout(); try { foreach (var g in gruppiDoppi) { var daRimuovere = g.Skip(1).ToList(); foreach (var d in daRimuovere) { _elencoDestintari.Remove(d); AppRepo.RemoveDestinatario(d.Id); } } } finally { dataGridView1.ResumeLayout(); } } } }
public string ValidateInput() { if (_domainData == null) { return("Chưa có dữ liệu"); } if (string.IsNullOrEmpty(DonHang_KhachHangId.Text)) { return(string.Format("Không được phép để trống {0}!", lblKhachHangId.Text)); } if (string.IsNullOrEmpty(DonHang_LoaiTienTe.Text)) { return(string.Format("Không được phép để trống {0}!", lblLoaiTienTe.Text)); } if (_chiTietDonhang.Count(s => s.IsActived) == 0) { return("Chưa nhập hàng hóa cho đơn hàng"); } foreach (var chiTietDonHang in _chiTietDonhang) { if (!chiTietDonHang.IsActived) { continue; } if (chiTietDonHang.HangHoaId == 0) { return("Không được để trống hàng hóa"); } if (chiTietDonHang.SoLuong <= 0) { return("Số lượng phải > 0"); } if (_domainData.TrangThai == Define.TrangThaiDonHang.Moi.ToString() && !chiTietDonHang.KhoHang.IsActived) { return(string.Format("{0} hiện đã ngưng kinh doanh.", chiTietDonHang.TenHangHoa)); } } if (_loaiDonHang == Define.LoaiDonHangEnum.XuatKho) { var groupByHangHoa = _chiTietDonhang.GroupBy(s => s.KhoHang); foreach (var hanghoa in groupByHangHoa) { var soLuongXuat = hanghoa.Where(s => s.IsActived).Sum(s => s.SoLuong); if (hanghoa.Key.SoLuong < soLuongXuat) { return(string.Format("Không đủ hàng. Chỉ còn {0} {1} trong kho", hanghoa.Key.SoLuong, hanghoa.Key.TenHang)); } } } //if (_domainData.ThanhToan > 0) //{ // var congNoDangThanhToan = _domainData.CongNoes.Any(s => s.ThanhToanCongNoes.Any()); // if (congNoDangThanhToan) // { // return string.Format("Đơn hàng này đang trong quá trình thanh toán nên không thể chỉnh sửa!"); // } //} if (_domainData.ThanhToan > _domainData.TongCong) { return("Số tiền thanh toán lớn hơn giá trị đơn hàng."); } if (_domainData.KhachHangId == Define.KhachLeId && _domainData.ThanhToan < _domainData.TongCong) { return("Khách lẻ không được nợ tiền"); } return(string.Empty); }
private void uc_menu_event_btnAprobarGuardarSalir_Click(object sender, EventArgs e) { try { txt_codigo.Focus(); if (blst.Where(q => q.opd_EstadoProceso != "AJC").Count() > 0) { MessageBox.Show("Para aprobar el pedido todos los items deben ser aprobados por el jefe de compras", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } var lst = blst.GroupBy(q => q.IdCotizacion).ToList(); foreach (var item in lst) { var cotizacion = bus_cotizacion.GetInfoAprobar(param.IdEmpresa, item.Key); if (cotizacion != null) { cotizacion.ObservacionAprobador = txt_ObservacionApro.Text; cotizacion.EstadoGA = blst.Where(q => q.IdCotizacion == item.Key && q.A == true).Count() > 0 ? "A" : "R"; cotizacion.IdUsuario = param.IdUsuario; cotizacion.ListaDetalle = new List <com_CotizacionPedidoDet_Info>(blst.Where(q => q.IdCotizacion == item.Key).Select(q => new com_CotizacionPedidoDet_Info { IdEmpresa = param.IdEmpresa, IdCotizacion = q.IdCotizacion, Secuencia = q.Secuencia, opd_IdEmpresa = q.opd_IdEmpresa, opd_IdOrdenPedido = q.opd_IdOrdenPedido, opd_Secuencia = q.opd_Secuencia, IdProducto = q.IdProducto ?? 0, cd_Cantidad = q.cd_Cantidad, cd_precioCompra = q.cd_precioCompra, cd_porc_des = q.cd_porc_des, cd_descuento = q.cd_descuento, cd_precioFinal = q.cd_precioFinal, cd_subtotal = q.cd_subtotal, IdCod_Impuesto = q.IdCod_Impuesto, Por_Iva = q.Por_Iva, cd_iva = q.cd_iva, cd_total = q.cd_total, IdUnidadMedida = q.IdUnidadMedida, IdPunto_cargo = q.IdPunto_cargo, EstadoGA = q.A, A = q.A, cd_DetallePorItem = q.cd_DetallePorItem, IdSucursalDestino = q.IdSucursalDestino, opd_Detalle = q.opd_Detalle }).ToList()); if (!bus_cotizacion.AprobarDB(cotizacion, "GA")) { return; } } } bus_pedido.ValidarProceso(param.IdEmpresa, IdOrdenPedido); MessageBox.Show("Pedido # " + txt_IdOrdenPedido.Text + " actualizado exitósamente", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); } catch (Exception) { } }
public Dictionary <string, bool> AddToDictionary(BindingList <LanguageDetails> languages) { // transform the languages into dictionary (used to deselect the single file projects languages) return(languages.GroupBy(l => l.LanguageName).ToDictionary(lg => lg.Key, lg => lg.First().IsChecked)); }
private bool Validar() { try { txtIdNumMoviDestino.Focus(); gvDetalle.MoveNext(); if (cmbSucursalOrigen.EditValue == null) { MessageBox.Show("El campo sucursal origen es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (cmbBodegaOrigen.EditValue == null) { MessageBox.Show("El campo bodega origen es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (cmbSucursalDestino.EditValue == null) { MessageBox.Show("El campo sucursal destino es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (cmbBodegaDestino.EditValue == null) { MessageBox.Show("El campo bodega destino es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (blstDetalle.Count == 0) { MessageBox.Show("Debe seleccionar al menos un producto a ser transferido", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in blstDetalle) { if (item.dt_cantidad == 0) { MessageBox.Show("No se ha ingresado la cantidad a transferir para el producto: " + item.pr_descripcion, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(item.IdUnidadMedida)) { MessageBox.Show("No se ha ingresado la unidad de medida para el producto: " + item.pr_descripcion, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(item.pr_descripcion)) { MessageBox.Show("Existen productos sin descripción", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } if (chkGenerarGuia.Checked) { if (blstDetalle.Where(q => q.EnviarEnGuia == true).Count() == 0) { MessageBox.Show("No ha seleccionado productos para enviar en la guia", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(txtDireccionOrigen.Text)) { MessageBox.Show("El campo punto de partida es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(txtDireccionDestino.Text)) { MessageBox.Show("El campo punto de llegada es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(txtIdentificacion.Text)) { MessageBox.Show("El campo identifiación es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(txtDestinatario.Text)) { MessageBox.Show("El campo destinatario es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (cmbTransportista.EditValue == null) { MessageBox.Show("El campo transportista es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (string.IsNullOrEmpty(txtPlaca.Text)) { MessageBox.Show("El campo placa es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (cmbMotivo.EditValue == null) { MessageBox.Show("El campo motivo es obligatorio", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } if (infoParam.Maneja_Stock_Negativo == "N") { #region ValidarStock /* * var lst = blstDetalle.Where(Q => Q.IdProducto != null).GroupBy(q => new { q.IdProducto, q.pr_descripcion }).Select(Q => new * { * IdProducto = Q.Key.IdProducto, * pr_descripcion = Q.Key.pr_descripcion, * Cantidad = Q.Sum(q => q.dt_cantidad), * CantidadAnterior = Q.Sum(q => q.CantidadAnterior) * }); */ var lst = blstDetalle.Where(Q => Q.IdProducto != null).GroupBy(q => new { q.IdProducto, q.pr_descripcion, q.IdUnidadMedida }).Select(Q => new { IdProducto = Q.Key.IdProducto, pr_descripcion = Q.Key.pr_descripcion, Cantidad = busUnidadMedida.GetCantidadConvertida(param.IdEmpresa, Q.Key.IdProducto ?? 0, Q.Key.IdUnidadMedida, Q.Sum(q => q.dt_cantidad)), CantidadAnterior = busUnidadMedida.GetCantidadConvertida(param.IdEmpresa, Q.Key.IdProducto ?? 0, Q.Key.IdUnidadMedida, Q.Sum(q => q.CantidadAnterior)) }); lst = lst.Where(Q => Q.IdProducto != null).GroupBy(q => new { q.IdProducto, q.pr_descripcion }).Select(Q => new { IdProducto = Q.Key.IdProducto, pr_descripcion = Q.Key.pr_descripcion, Cantidad = Q.Sum(q => q.Cantidad), CantidadAnterior = Q.Sum(q => q.CantidadAnterior) }); string pr_descripcion = string.Empty; foreach (var item in lst) { pr_descripcion = string.Empty; if (!busProducto.ValidarStock(param.IdEmpresa, Convert.ToInt32(cmbSucursalOrigen.EditValue), Convert.ToInt32(cmbBodegaOrigen.EditValue), item.IdProducto ?? 0, item.Cantidad, item.CantidadAnterior, ref pr_descripcion)) { MessageBox.Show("El producto " + pr_descripcion + " no tiene stock suficiente para la transferencia.", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } #endregion } if (Accion == Cl_Enumeradores.eTipo_action.grabar && infoParam.P_ValidarDiasHaciaAtras != null && infoParam.P_ValidarDiasHaciaAtras != 0) { // Difference in days, hours, and minutes. TimeSpan ts = deFecha.DateTime.Date - DateTime.Now.Date; int differenceInDays = ts.Days; if (differenceInDays < infoParam.P_ValidarDiasHaciaAtras) { MessageBox.Show("No se puede registrar una transacción anterior a los dias permitidos de atraso\nDias de atraso permitidos: " + infoParam.P_ValidarDiasHaciaAtras.ToString(), param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } #region ValidacionProductoPorBodega in_ProductoPor_tb_bodega_Bus busProductoPorBodega = new in_ProductoPor_tb_bodega_Bus(); string mensajeValidacion = string.Empty; List <decimal> ListaProducto = blstDetalle.GroupBy(q => q.IdProducto ?? 0).Select(q => q.Key).ToList(); string Retorno = busProductoPorBodega.Validar(param.IdEmpresa, Convert.ToInt32(cmbSucursalOrigen.EditValue), Convert.ToInt32(cmbBodegaOrigen.EditValue), ListaProducto); string Retorno2 = busProductoPorBodega.Validar(param.IdEmpresa, Convert.ToInt32(cmbSucursalDestino.EditValue), Convert.ToInt32(cmbBodegaDestino.EditValue), ListaProducto); Retorno += string.IsNullOrEmpty(Retorno2) ? "" : ("\n" + Retorno2); if (!string.IsNullOrEmpty(Retorno)) { mensajeValidacion += (string.IsNullOrEmpty(mensajeValidacion) ? "" : "\n") + Retorno; } if (!string.IsNullOrEmpty(mensajeValidacion)) { MessageBox.Show(mensajeValidacion, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } #endregion return(true); } catch (Exception ex) { busLogError.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void обновить() { de = new domofon14Entities(); tempList.Clear(); foreach (услуги yRow in de.услуги .Where(n => n.вид_услуги == клВид_услуги.вид_услуги) .OrderBy(n => n.порядок)) { foreach (сотрудники sRow in de.сотрудники .OrderBy(n => n.порядок)) { int повторов = sRow.повторы .Where(n => n.дата_с >= клПериод.дата_с) .Where(n => n.дата_с <= клПериод.дата_по) .Count(n => n.услуга == yRow.услуга); int отключений = sRow.отключения .Where(n => n.дата_с >= клПериод.дата_с) .Where(n => n.дата_с <= клПериод.дата_по) .Count(n => n.услуга == yRow.услуга); int договоров = sRow.подключения .Where(n => n.дата_с >= клПериод.дата_с) .Where(n => n.дата_с <= клПериод.дата_по) .Count(n => n.услуга == yRow.услуга); if (повторов > 0 || отключений > 0 || договоров > 0) { // DsTemp.отключенийRow NewRow = dsTemp.отключений.NewотключенийRow(); temp NewRow = new temp(); NewRow.услуга = yRow.услуга; NewRow.мастер = sRow.сотрудник; NewRow.должность = sRow.должность; NewRow.фио = sRow.фио; NewRow.отключено = отключений; NewRow.повторно = повторов; NewRow.подключено = договоров; NewRow.наимен_услуги = yRow.обозначение; tempList.Add(NewRow); } } } var queryAll = tempList .GroupBy(n => new { n.услуга, n.наимен_услуги }) .Select(n => new { n.Key.услуга, n.Key.наимен_услуги, откл = n.Sum(p => p.отключено), повтор = n.Sum(p => p.повторно), договоров = n.Sum(p => p.подключено) }); foreach (var aRow in queryAll) { temp NewRow = new temp(); NewRow.услуга = aRow.услуга; NewRow.мастер = Guid.Empty; NewRow.должность = ""; NewRow.фио = "Всего"; NewRow.отключено = aRow.откл; NewRow.повторно = aRow.повтор; NewRow.подключено = aRow.договоров; NewRow.наимен_услуги = aRow.наимен_услуги; tempList.Add(NewRow); } bindingSource1.DataSource = tempList; dataGridView1.DataSource = bindingSource1; dataGridView1.Refresh(); dataGridView1.Focus(); }