private void gridControl1_CellDoubleClick(object sender, EventArgs e) { // OVP_3.ClassAct.ConvertDate.StartTimer(); var db = new DataClasses1DataContext(); CurrencyManager cmgr = (CurrencyManager)this.gridControl1.BindingContext[this.gridControl1.DataSource]; var sklad = (SkladPrih)cmgr.Current; var beginDate = barEditItem2.EditValue; var endDate = barEditItem3.EditValue; var prihs = db.T_KATSOPR.Where( x => x.F_DOPR >= ConvertDate.intdate((DateTime)beginDate) & x.F_DOPR <= ConvertDate.intdate((DateTime)endDate) && x.F_VIDSOPR == 101 && x.F_CPODRTO == sklad.nrec).Select(o => new Prih() { nrec = o.F_NREC, }).ToList <Prih>(); var itog = new List <Prih>(); foreach (var pr in prihs) { var sp = db.T_SPSOPR.Where(x => x.F_CSOPR == pr.nrec).Select(o => new Prih() { nomNum = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_BARKOD, obozn = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL) != null ? db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_OBOZN : " ", naim = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL) != null ? db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_NAME : " ", kol = (double)o.F_KOL, edizm = db.T_KATOTPED.First(x => x.F_NREC == o.F_COTPED).F_NAME, price = (double)o.F_PRICE, summa = (double)o.F_KOL * (double)o.F_PRICE, groupSnab = (db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN)) != null ? (Convert.ToInt32(db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN).F_CANALIT_5_.ToArray().GetValue(7))) : (int?)null, vidPriemki = (db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN)) != null ? (Convert.ToInt32(db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN).F_CANALIT_2_.ToArray().GetValue(7))) : (int?)null, contragent = db.T_KATORG.First(t => t.F_NREC == db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_CORG).F_NAME, unn = db.T_KATORG.First(t => t.F_NREC == db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_CORG).F_UNN, code = db.T_KATORG.First(t => t.F_NREC == db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_CORG).F_CODE, naklNum = db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_NSOPR, dateNakl = ConvertDate.dateint(db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_DSOPR), orderNum = db.T_SKLORDER.First(y => y.F_CSOPR == db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_NREC).F_NORDER, datePrih = ConvertDate.dateint(db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_DOPR), }).ToList <Prih>(); itog = itog.Concat(sp).ToList <Prih>(); } // OVP_3.ClassAct.ConvertDate.EndTimer(); gridControl2.DataSource = itog; }
private void gridControl1_CellDoubleClick(object sender, EventArgs e) { OVP_3.ClassAct.ConvertDate.StartTimer(); var db = new DataClasses1DataContext(); CurrencyManager cmgr = (CurrencyManager)this.gridControl1.BindingContext[this.gridControl1.DataSource]; var kontr = (KontrPrih)cmgr.Current; var beginDate = barEditItem25.EditValue; var endDate = barEditItem18.EditValue; var prihs = db.T_KATSOPR.Where( x => x.F_DOPR >= ConvertDate.intdate((DateTime)beginDate) & x.F_DOPR <= ConvertDate.intdate((DateTime)endDate) && x.F_VIDSOPR == 101 && x.F_CORG == kontr.nrec).Select(o => new Prih() { nrec = o.F_NREC, }).ToList <Prih>(); var itog = new List <Prih>(); foreach (var pr in prihs) { var sp = db.T_SPSOPR.Where(x => x.F_CSOPR == pr.nrec).Select(o => new Prih() { nomNum = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_BARKOD, obozn = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL) != null ? db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_OBOZN : " ", naim = db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL) != null ? db.T_KATMC.First(x => x.F_NREC == o.F_CMCUSL).F_NAME : " ", kol = (double)o.F_KOL, edizm = db.T_KATOTPED.First(x => x.F_NREC == o.F_COTPED).F_NAME, price = (double)o.F_PRICE, summa = String.Format("{0:0.00}", (decimal)((double)o.F_KOL * (double)o.F_PRICE)), groupSnab = (db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN)) != null ? (Convert.ToInt32(db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN).F_CANALIT_5_.ToArray().GetValue(7))) : (int?)null, vidPriemki = (db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN)) != null ? (Convert.ToInt32(db.T_HASHANs.First(x => x.F_NREC == db.T_KATMC.First(y => y.F_NREC == o.F_CMCUSL).F_CHASHAN).F_CANALIT_2_.ToArray().GetValue(7))) : (int?)null, naklNum = db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_NSOPR, dateNakl = ConvertDate.dateint(db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_DSOPR), orderNum = db.T_SKLORDER.First(y => y.F_CSOPR == db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_NREC).F_NORDER, datePrih = ConvertDate.dateint(db.T_KATSOPR.First(x => x.F_NREC == o.F_CSOPR).F_DOPR), sklad = (db.T_KATPODR.First(x => x.F_NREC == db.T_KATSOPR.First(y => y.F_NREC == o.F_CSOPR).F_CPODRTO).F_NAME), ndsSumma = (double)o.F_KOL * (double)o.F_PRICE + (double)o.F_SUMNDS }).ToList <Prih>(); itog = itog.Concat(sp).ToList <Prih>(); } int i = 0; int a = 0; double allSumNds = 0; foreach (var pr in itog) { if (itog.Count == 1) { allSumNds = itog[i].ndsSumma; pr.summa = pr.summa + " Итого c НДС: " + String.Format("{0:0.00}", (decimal)(allSumNds)); } else { if (i == (itog.Count - 1)) { for (int j = a; j <= (itog.Count - 1); j++) { allSumNds += itog[j].ndsSumma; } pr.summa = pr.summa + " Итого c НДС: " + String.Format("{0:0.00}", (decimal)(allSumNds)); a = i + 1; allSumNds = 0; } else if (itog[i].orderNum != itog[i + 1].orderNum) { for (int j = a; j <= i; j++) { allSumNds += itog[j].ndsSumma; } pr.summa = pr.summa + " Итого c НДС: " + String.Format("{0:0.00}", (decimal)(allSumNds)); a = i + 1; allSumNds = 0; } } i++; } OVP_3.ClassAct.ConvertDate.EndTimer(); gridControl2.DataSource = itog; }