public bool Add(Accountant accountant) { try { string sql = "INSERT INTO accountant values(?AccountantId,?Account,?PassWord,?Name)"; MySqlParameter[] parameter = new MySqlParameter[] { new MySqlParameter("?AccountantId", accountant.AccountantId), new MySqlParameter("?Account", accountant.Account), new MySqlParameter("?PassWord", accountant.PassWord) , new MySqlParameter("?Name", accountant.Name) }; return MySqlHelper.ExecuteNonQuery(CommandType.Text, sql, parameter) == 1; } catch (Exception e) { MySqlHelper.CloseDBConnection(); throw e; } finally { } }
private void chkBackupAuthentication_CheckedChanged(object sender, EventArgs e) { Accountant _obj = mApplicationController.mAccountant; _obj.ConfigMgr.SetParam("BACKUP_AUTHENTICATION", chkBackupAuthentication.Checked ? "1" : "0"); }
// // GET: /Admin/AdminAccountant/ public ActionResult CashBook() { using (var db = new Data_MassageEntities1()) { var chi = db.tbl_Phieu_Chi.ToList(); List <Accountant> kho = new List <Accountant> { }; foreach (var item in chi) { if (kho == null) { var item1 = new Accountant(); var list1 = new List <Accountant>(); item1.chuky_nguoinhan = item.chuky_nguoinhan; item1.diachi = item.diachi; item1.Id = item.Id; item1.ngaylap = item.ngaylap; item1.nguoilap = item.nguoilap; item1.nguoinhan = item.nguoinhan; item1.nguoinop = item.nguoinhan; item1.nguoinoptien = item.nguoinhan; item1.noidungchi = item.noidungchi; item1.noidungthu = item.noidungchi; item1.Note_chi = item.Note_chi; item1.Note_thu = item.Note_chi; item1.sodienthoai = item.sodienthoai; item1.sotien_chi = (float)item.sotien_chi; item1.sotien_thu = 0; item1.sochungtu_thu = item.sochungtu_chi; var y = item1.sotien_chi; var x = item1.sotien_thu; item1.sotienton = x - y; kho.Add(item1); } else { var item1 = new Accountant(); var list1 = new List <Accountant>(); item1.chuky_nguoinhan = item.chuky_nguoinhan; item1.diachi = item.diachi; item1.Id = item.Id; item1.ngaylap = item.ngaylap; item1.nguoilap = item.nguoilap; item1.nguoinhan = item.nguoinhan; item1.nguoinop = item.nguoinhan; item1.nguoinoptien = item.nguoinhan; item1.noidungchi = item.noidungchi; item1.noidungthu = item.noidungchi; item1.Note_chi = item.Note_chi; item1.Note_thu = item.Note_chi; item1.sodienthoai = item.sodienthoai; item1.sotien_thu = 0; item1.sochungtu_thu = item.sochungtu_chi; if (item.sotien_chi == null) { item.sotien_chi = 0; } item1.sotien_chi = (float)item.sotien_chi; var y = item1.sotien_chi; var x = item1.sotien_thu; item1.sotienton = x - y; kho.Add(item1); } } var thu = db.phieu_thu.ToList(); foreach (var item in thu) { if (kho == null) { var item1 = new Accountant(); var list1 = new List <Accountant>(); item1.chuky_nguoinhan = item.nguoinop; item1.diachi = item.diachi; item1.Id = item.Id; item1.ngaylap = item.ngaylap; item1.nguoilap = item.nguoilap; item1.nguoinhan = item.nguoinop; item1.nguoinop = item.nguoinoptien; item1.nguoinoptien = item.nguoinoptien; item1.noidungchi = item.noidungthu; item1.noidungthu = item.noidungthu; item1.Note_chi = item.Note_thu; item1.sodienthoai = item.sodienthoai; item1.sochungtu_thu = item.sochungtu_thu; item1.sotien_chi = 0; item1.sotien_thu = (float)item.sotien_thu; item1.sotienton = item1.sotien_thu - item1.sotien_chi; kho.Add(item1); } else { var item1 = new Accountant(); var list1 = new List <Accountant>(); item1.chuky_nguoinhan = item.nguoinop; item1.diachi = item.diachi; item1.Id = item.Id; item1.ngaylap = item.ngaylap; item1.nguoilap = item.nguoilap; item1.nguoinhan = item.nguoinop; item1.nguoinop = item.nguoinoptien; item1.nguoinoptien = item.nguoinoptien; item1.noidungchi = item.noidungthu; item1.noidungthu = item.noidungthu; item1.Note_chi = item.Note_thu; item1.sodienthoai = item.sodienthoai; item1.sochungtu_thu = item.sochungtu_thu; item1.sotien_chi = 0; if (item.sotien_thu == null) { item.sotien_thu = 0; } item1.sotien_thu = (float)item.sotien_thu; item1.sotienton = item1.sotien_thu - item1.sotien_chi; kho.Add(item1); } } ViewData["list_quy_tien"] = kho.OrderBy(x => x.sotien_thu).OrderByDescending(x => x.ngaylap).ToList(); return(View()); } }
private void RunMark(IVoucherDetailQuery filt, CsvParser parsed, string marker, StringBuilder sb) { if (filt.IsDangerous()) { throw new SecurityException("检测到弱检索式"); } var marked = 0; var remarked = 0; var converted = 0; var res = Accountant.SelectVouchers(filt.VoucherQuery).ToList(); foreach (var b in parsed.Items) { bool Trial(bool date) { var resx = date ? res.Where(v => v.Date == b.Date) : res.OrderBy(v => v.Date.HasValue ? Math.Abs((v.Date.Value - b.Date).TotalDays) : double.PositiveInfinity); var voucher = resx .Where(v => v.Details.Any(d => (d.Fund.Value - b.Fund).IsZero() && d.IsMatch(filt.DetailEmitFilter.DetailFilter))) .FirstOrDefault(); if (voucher == null) { return(false); } var o = voucher.Details.First(d => (d.Fund.Value - b.Fund).IsZero() && d.IsMatch(filt.DetailEmitFilter.DetailFilter)); if (o.Remark == null) { marked++; } else if (o.Remark == marker) { remarked++; } else { converted++; } o.Remark = marker; Accountant.Upsert(voucher); return(true); } if (Trial(true) || Trial(false)) { continue; } sb.AppendLine(b.Raw); } sb.AppendLine($"{marked} marked"); sb.AppendLine($"{remarked} remarked"); sb.AppendLine($"{converted} converted"); }
public PluginShell(Accountant helper) => m_Plugins =
public BLLTest() { m_Accountant = new(new(db : "accounting-test"), "b1", DateTime.UtcNow.Date); m_Accountant.DeleteVouchersAsync(VoucherQueryUnconstrained.Instance).AsTask().Wait(); }
private IQueryResult Query(string content, ref string expr) { var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; var trans = new List <Trans>(); var rebates = new List <Rebate>(); var convs = new List <Conversion>(); foreach (var voucher in Accountant.RunVoucherQuery($"T224101 {content.Quotation('\'')} {rng.AsDateRange()}") ) { var ds = voucher.Details.Where(d => d.Title == 2241 && d.SubTitle == 01 && d.Content == content) .ToList(); if (ds.Count > 2) { throw new ApplicationException("过多相关细目"); } if (ds.Count == 2) { // ReSharper disable PossibleInvalidOperationException var v1 = ds[0].Fund.Value; var v2 = ds[1].Fund.Value; // ReSharper restore PossibleInvalidOperationException if (v1 < 0 && v2 > 0) { convs.Add( new Conversion { Date = voucher.Date, TargetCurrency = ds[0].Currency, TargetFund = -v1, OriginCurrency = ds[1].Currency, OriginFund = v2, }); continue; } if (v1 > 0 && v2 < 0) { convs.Add( new Conversion { Date = voucher.Date, TargetCurrency = ds[1].Currency, TargetFund = -v2, OriginCurrency = ds[0].Currency, OriginFund = v1, }); continue; } } trans.AddRange( // ReSharper disable once PossibleInvalidOperationException ds.Where(d => d.Fund.Value < 0) .Select( d => new Trans { Date = voucher.Date, RawCurrency = d.Currency, RawFund = -d.Fund.Value })); } foreach (var voucher in Accountant.RunVoucherQuery( $"{{T224101 {content.Quotation('\'')}}}*{{T660300}}*{{T224101 {content.Quotation('\'')} +T3999+T660300 A {rng.AsDateRange()}}}") ) { // Assume proper ordering here var d0 = voucher.Details.Single(d => d.Title == 2241); var d1 = voucher.Details.Single(d => d.Title == 6603); if (d0.Title != 2241 || d0.SubTitle != 01 || d0.Content != content) { continue; } if (d1.Title != 6603 || d1.SubTitle != null || d1.Content != null) { continue; } if (!d0.Fund.HasValue || !d1.Fund.HasValue) { continue; } rebates.Add( new Rebate { Date = voucher.Date, RawCurrency = d1.Currency, RawFund = d1.Fund.Value, TheConversion = new Conversion { Date = voucher.Date, OriginCurrency = d1.Currency, OriginFund = d1.Fund.Value, TargetCurrency = d0.Currency, TargetFund = d0.Fund.Value, }, }); } foreach (var tran in trans) { var conv = convs.FirstOrDefault( c => c.Date >= tran.Date && c.OriginCurrency == tran.RawCurrency && (c.OriginFund - tran.RawFund).IsZero()); if (conv == null) { continue; } tran.TheConversion = conv; convs.Remove(conv); } var sb = new StringBuilder(); foreach (var conv in convs) { sb.Append(conv.Date.AsDate()); sb.Append($" @{conv.OriginCurrency} {conv.OriginFund.AsCurrency().CPadLeft(15)}"); sb.AppendLine( $" {conv.Date.AsDate()} @{conv.TargetCurrency} {conv.TargetFund.AsCurrency().CPadLeft(15)} !!!"); } if (sb.Length != 0) { sb.AppendLine("==========================================================="); } foreach (var tran in trans.Concat(rebates).OrderByDescending(t => t.Date)) { sb.Append(tran.Date.AsDate()); sb.Append($" @{tran.RawCurrency} {tran.RawFund.AsCurrency().CPadLeft(15)}"); if (tran.TheConversion != null) { sb.AppendLine( $" {tran.TheConversion.Date.AsDate()} @{tran.TheConversion.TargetCurrency} {tran.TheConversion.TargetFund.AsCurrency().CPadLeft(15)}"); } else { sb.AppendLine(); } } return(new PlainText(sb.ToString())); }
private IQueryResult Create(string content, ref string expr, IEntitiesSerializer serializer) { var currency = Parsing.Token(ref expr, false); var baseCurrency = Parsing.Token(ref expr, false); var lst = new List <Voucher>(); while (!string.IsNullOrWhiteSpace(expr)) { var date = Parsing.UniqueTime(ref expr); if (!date.HasValue) { var dayF = ParsingF.DoubleF(ref expr); var day = (int)dayF; // ReSharper disable once CompareOfFloatsByEqualityOperator if (day != dayF) { throw new ApplicationException("非整数日期"); } date = ClientDateTime.Today.Day < day ? ClientDateTime.Today.AddMonths(-1).AddDays(day - ClientDateTime.Today.Day) : ClientDateTime.Today.AddDays(day - ClientDateTime.Today.Day); } var from = ParsingF.DoubleF(ref expr); var to = ParsingF.DoubleF(ref expr); var voucher = new Voucher { Date = date.Value, Details = new List <VoucherDetail> { new VoucherDetail { Currency = baseCurrency, Title = 2241, SubTitle = 01, Content = content, Fund = -to, }, new VoucherDetail { Currency = baseCurrency, Title = 3999, Fund = to }, new VoucherDetail { Currency = currency, Title = 3999, Fund = -from }, from >= 0 ? new VoucherDetail { Currency = currency, Title = 2241, SubTitle = 01, Content = content, Fund = from, } : new VoucherDetail { Currency = currency, Title = 6603, Fund = from }, }, }; Accountant.Upsert(voucher); lst.Add(voucher); } if (lst.Any()) { return(new DirtyText(serializer.PresentVouchers(lst))); } return(new PlainSucceed()); }
public BOPurchaseOrder(Accountant accountant, Purchase _obj, BOContext _state) : base(accountant, _obj, _state) { mObjectID = BOType.BOPurchaseOrder; mDataProxy.PurchaseStatus = mAccountant.StatusMgr.Status_Order; }
public CarryYearShell(Accountant helper) => m_Accountant = helper;
/// <inheritdoc /> public override IQueryResult Execute(string expr, IEntitiesSerializer serializer) { var content = Parsing.Token(ref expr); var avg = Parsing.DoubleF(ref expr); Parsing.Eof(expr); var tdy = ClientDateTime.Today; var ldom = AccountantHelper.LastDayOfMonth(tdy.Year, tdy.Month); var srng = new DateFilter(new DateTime(tdy.Year, tdy.Month, 1, 0, 0, 0, DateTimeKind.Utc), tdy); var balance = Accountant.RunGroupedQuery( $"T1002 {content.Quotation('\'')} [~{tdy.AsDate()}]`vD{srng.AsDateRange()}"); var bal = 0D; var btd = 0D; foreach (var b in balance.Items.Cast <ISubtotalDate>()) { if (b.Date == tdy) { btd += b.Fund; } else { bal += b.Fund; } } var targ = ldom.Day * avg; var sb = new StringBuilder(); sb.AppendLine($"Target: {targ.AsCurrency()}"); sb.AppendLine($"Balance until yesterday: {bal.AsCurrency()}"); if ((bal - targ).IsNonNegative()) { sb.AppendLine("Achieved."); sb.AppendLine(); sb.AppendLine( (btd - avg).IsNonNegative() ? $"Plan A: Credit {(btd - avg).AsCurrency()}, Balance {avg.AsCurrency()}" : $"Plan A: Debit {(avg - btd).AsCurrency()}, Balance {avg.AsCurrency()}"); sb.AppendLine("Plan B: No Action"); } else { var res = targ - bal; var rsd = ldom.Day - tdy.Day + 1; sb.AppendLine($"Deficiency: {res.AsCurrency()}"); var avx = res / rsd; if ((rsd * avg - res).IsNonNegative()) { sb.AppendLine($"Average deficiency: {avx.AsCurrency()} <= {avg.AsCurrency()}"); sb.AppendLine(); sb.AppendLine( (btd - avx).IsNonNegative() ? $"Plan A: Credit {(btd - avx).AsCurrency()}, Balance {avx.AsCurrency()}" : $"Plan A: Debit {(avx - btd).AsCurrency()}, Balance {avx.AsCurrency()}"); sb.AppendLine( (btd - avg).IsNonNegative() ? $"Plan B: Credit {(btd - avg).AsCurrency()}, Balance {avg.AsCurrency()}" : $"Plan B: Debit {(avg - btd).AsCurrency()}, Balance {avg.AsCurrency()}"); } else { sb.AppendLine($"Average deficiency: {avx.AsCurrency()} > {avg.AsCurrency()}"); sb.AppendLine(); sb.AppendLine( (btd - avx).IsNonNegative() ? $"Plan: Credit {(btd - avx).AsCurrency()}, Balance {avx.AsCurrency()}" : $"Plan: Debit {(avx - btd).AsCurrency()}, Balance {avx.AsCurrency()}"); } } return(new PlainText(sb.ToString())); }
public AverageDailyBalance(Accountant accountant) : base(accountant) { }
public BaseCurrencyShell(Accountant helper) => m_Accountant = helper;
protected PluginBase(Accountant accountant) => Accountant = accountant;
public ItemsListSummaryRpt(Accountant acc) : base(acc) { }
public bool Update(Accountant accountant) { try { string sql = "UPDATE accountant SET Account=?Account,PassWord=?PassWord,Name=?Name WHERE AccountantId=?AccountantId"; MySqlParameter[] parameter = new MySqlParameter[] { new MySqlParameter("?AccountantId", accountant.AccountantId), new MySqlParameter("?Account", accountant.Account), new MySqlParameter("?PassWord", accountant.PassWord) , new MySqlParameter("?Name", accountant.Name) }; return MySqlHelper.ExecuteNonQuery(CommandType.Text, sql, parameter) == 1; } catch (Exception e) { MySqlHelper.CloseDBConnection(); throw e; } finally { } }
public YieldRate(Accountant accountant) : base(accountant) { }
/// <summary> /// 从上次计息日后一日起计算单利利息并整理还款 /// </summary> /// <param name="info">借款信息</param> /// <param name="capitalIntegral">剩余本金</param> /// <param name="interestIntegral">剩余利息</param> /// <param name="lastSettlement">上次计息日</param> /// <param name="finalDay">截止日期</param> private void Regularize(LoanInfo info, ref double capitalIntegral, ref double interestIntegral, DateTime? lastSettlement, DateTime finalDay) { var capitalPattern = info.AsCapital(this); var interestPattern = info.AsInterest(this); var rng = lastSettlement.HasValue ? new DateFilter(lastSettlement.Value.AddDays(1), finalDay) : new DateFilter(null, finalDay); foreach (var grp in Accountant .RunVoucherQuery($"{info.QueryMajor(this)} {rng.AsDateRange()}") .GroupBy(v => v.Date) .OrderBy(grp => grp.Key, new DateComparer())) { var key = grp.Key ?? throw new ApplicationException("无法处理无穷长时间以前的利息收入"); if (!lastSettlement.HasValue) lastSettlement = key; // Settle Interest interestIntegral += SettleInterest( info, capitalIntegral, key.Subtract(lastSettlement.Value).Days, grp.SingleOrDefault( v => v.Details.Any(d => d.IsMatch(interestPattern, Dir()))) ?? new Voucher { Date = key, Details = new List<VoucherDetail>() }); lastSettlement = key; // Settle Loan // ReSharper disable once PossibleInvalidOperationException capitalIntegral += grp.SelectMany(v => v.Details.Where(d => d.IsMatch(capitalPattern, Dir()))) .Select(d => d.Fund.Value) .Sum(); // Settle Return foreach ( var voucher in grp.Where( v => v.Details.Any( d => d.IsMatch(capitalPattern, -Dir()) || d.IsMatch(interestPattern, -Dir()))) .OrderBy(v => v.ID)) { // ReSharper disable once PossibleInvalidOperationException var value = -voucher.Details.Where( d => d.IsMatch(capitalPattern, -Dir()) || d.IsMatch(interestPattern, -Dir())) .Select(d => d.Fund.Value) .Sum(); if ((Dir() * (-value + interestIntegral)).IsNonNegative()) { RegularizeVoucherDetail(info, voucher, 0, value); interestIntegral -= value; } else { RegularizeVoucherDetail(info, voucher, value - interestIntegral, interestIntegral); capitalIntegral -= value - interestIntegral; interestIntegral = 0; } } } if (lastSettlement == null) throw new ApplicationException("无法处理无穷长时间以前的利息收入"); if (lastSettlement != finalDay) interestIntegral += SettleInterest( info, capitalIntegral, finalDay.Subtract(lastSettlement.Value).Days, new Voucher { Date = finalDay, Details = new List<VoucherDetail>() }); }
public CreditCardConvert(Accountant accountant) : base(accountant) { }
protected InterestBase(Accountant accountant) : base(accountant) { }
public CheckShell(Accountant helper) => m_Accountant = helper;
/// <summary> /// 正确登记还款 /// </summary> /// <param name="info">借款信息</param> /// <param name="voucher">记账凭证</param> /// <param name="capVol">本金还款额</param> /// <param name="intVol">利息还款额</param> private void RegularizeVoucherDetail(LoanInfo info, Voucher voucher, double capVol, double intVol) { var flag = false; var capFlag = false; var intFlag = false; for (var i = 0; i < voucher.Details.Count; i++) { if (voucher.Details[i].IsMatch(info.AsCapital(this), -Dir())) { if (capFlag || capVol.IsZero()) { voucher.Details.RemoveAt(i); flag = true; i--; continue; } // ReSharper disable once PossibleInvalidOperationException if (!(voucher.Details[i].Fund.Value - capVol).IsZero()) { voucher.Details[i].Fund = -capVol; flag = true; } capFlag = true; } if (voucher.Details[i].IsMatch(info.AsInterest(this), -Dir())) { if (intFlag || intVol.IsZero()) { voucher.Details.RemoveAt(i); flag = true; i--; continue; } // ReSharper disable once PossibleInvalidOperationException if (!(voucher.Details[i].Fund.Value - intVol).IsZero()) { voucher.Details[i].Fund = -intVol; flag = true; } intFlag = true; } } if (!capFlag && !capVol.IsZero()) { voucher.Details.Add(info.AsCapital(this, -capVol)); flag = true; } if (!intFlag && !intVol.IsZero()) { voucher.Details.Add(info.AsInterest(this, -intVol)); flag = true; } if (flag) Accountant.Upsert(voucher); }
private void PopulateData(Excel.Worksheet ws) { Sheet1 sh1 = Globals.Sheet1; Sheet2 sh2 = Globals.Sheet2; int year_from = int.Parse(txtFromYear.Text); int year_to = int.Parse(txtToYear.Text); int SaleAmountColIndex = 0; int CostOfSalesAmountColIndex = 0; int GrossProfitColIndex = 0; int ProfitMarginColIndex = 0; double TotalSaleAmount = 0; double TotalCostOfSalesAmount = 0; double TotalGrossProfit = 0; double TotalProfitMargin = 0; bool oldSh2Locked = sh2.Locked; sh2.Locked = false; Excel.Range cell = null; Accountant _obj = AccountantPool.Instance.CurrentAccountant; IList <Item> items = _obj.ItemMgr.List(); int columnIndex = 1; int rowOffset = 7; if (chkItemNumber.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Item #"; cell.Font.Bold = true; } if (chkItemName.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Name"; cell.Font.Bold = true; } if (chkBatchNumber.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Batch #"; cell.Font.Bold = true; } if (chkSerialNumber.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Serial #"; cell.Font.Bold = true; } if (chkExpiryDate.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Expiry Date"; cell.Font.Bold = true; } if (chkBrand.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Brand"; cell.Font.Bold = true; } if (chkColor.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Color"; cell.Font.Bold = true; } if (chkGender.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Gender"; cell.Font.Bold = true; } if (chkSize.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Size"; cell.Font.Bold = true; } if (chkSaleAmount.Checked) { SaleAmountColIndex = columnIndex; cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Sales"; cell.Font.Bold = true; } if (chkCostOfSalesAmount.Checked) { CostOfSalesAmountColIndex = columnIndex; cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Cost of Sales"; cell.Font.Bold = true; } if (chkGrossProfit.Checked) { GrossProfitColIndex = columnIndex; cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Gross Profit"; cell.Font.Bold = true; } if (chkProfitMargin.Checked) { ProfitMarginColIndex = columnIndex; cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "%Margin"; cell.Font.Bold = true; } if (chkUnitsSold.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Units Sold"; cell.Font.Bold = true; } if (chkAverageCost.Checked) { cell = ws.Cells[rowOffset, columnIndex++] as Excel.Range; cell.Value2 = "Average Cost"; cell.Font.Bold = true; } int totalColCount = columnIndex - 1; ws.get_Range(ws.Cells[1, 1], ws.Cells[1, totalColCount]).Merge(missing); cell = ws.Cells[1, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; cell.Font.Bold = true; cell.Value2 = _obj.DataFileInformationMgr.Company.CompanyName; ws.get_Range(ws.Cells[2, 1], ws.Cells[2, totalColCount]).Merge(missing); cell = ws.Cells[2, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; cell.Font.Italic = true; cell.RowHeight = 48; cell.Value2 = _obj.DataFileInformationMgr.Company.Address; ws.get_Range(ws.Cells[3, 1], ws.Cells[3, totalColCount]).Merge(missing); cell = ws.Cells[3, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; cell.Font.Bold = true; cell.Value2 = "Analyse Sales [Item]"; ws.get_Range(ws.Cells[4, 1], ws.Cells[4, totalColCount]).Merge(missing); cell = ws.Cells[4, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; cell.Font.Bold = true; if (year_from == year_to) { cell.Value2 = string.Format("{0}", year_from); } else { cell.Value2 = string.Format("{0} - {1}", year_from, year_to); } ws.get_Range(ws.Cells[5, 1], ws.Cells[5, totalColCount]).Merge(missing); cell = ws.Cells[5, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; cell.Font.Bold = true; cell.Value2 = DateTime.Now.ToString("yyyy-MMM-dd"); ws.get_Range(ws.Cells[6, 1], ws.Cells[6, totalColCount]).Merge(missing); cell = ws.Cells[6, 1] as Excel.Range; cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; cell.Font.Bold = true; cell.Value2 = DateTime.Now.ToString("HH:mm:ss"); rowOffset++; int itemCount = items.Count; for (int i = 0; i < itemCount; ++i) { columnIndex = 1; LightItem _lght = sh2.GetItem(items[i].ItemNumber); if (chkItemNumber.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = items[i].ItemNumber; } if (chkItemName.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = items[i].ItemName; } if (chkBatchNumber.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.BatchNumber; } if (chkSerialNumber.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.SerialNumber; } if (chkExpiryDate.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.ExpiryDate.ToString("yyyy-MMM-dd"); } if (chkBrand.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.Brand; } if (chkColor.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.Color; } if (chkGender.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.Gender.ToString(); } if (chkSize.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _lght.Size.ToString(); } List <ItemSalesHistory> itemSalesHistories = _obj.ItemSalesHistoryMgr.List(items[i].ItemID, year_from, year_to); double SaleAmount = 0; if (chkSaleAmount.Checked || chkGrossProfit.Checked) { foreach (ItemSalesHistory history in itemSalesHistories) { SaleAmount += history.SaleAmount; } cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(SaleAmount); } double CostOfSalesAmount = 0; if (chkCostOfSalesAmount.Checked || chkGrossProfit.Checked) { foreach (ItemSalesHistory history in itemSalesHistories) { CostOfSalesAmount += history.CostOfSalesAmount; } cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(CostOfSalesAmount); } double GrossProfit = SaleAmount - CostOfSalesAmount; if (chkGrossProfit.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(GrossProfit); } double margin = 0; if (SaleAmount != 0) { margin = GrossProfit * 100 / SaleAmount; } if (chkProfitMargin.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.FormatPercent(margin); } if (chkUnitsSold.Checked) { double UnitsSold = 0; foreach (ItemSalesHistory history in itemSalesHistories) { UnitsSold += history.UnitsSold; } cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = UnitsSold.ToString(); } if (chkAverageCost.Checked) { cell = ws.Cells[i + rowOffset, columnIndex++] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(items[i].PositiveAverageCost); } TotalSaleAmount += SaleAmount; TotalProfitMargin += margin; TotalGrossProfit += GrossProfit; TotalCostOfSalesAmount += CostOfSalesAmount; } if (chkSaleAmount.Checked) { cell = ws.Cells[itemCount + rowOffset, SaleAmountColIndex] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(TotalSaleAmount / itemCount); } if (chkCostOfSalesAmount.Checked) { cell = ws.Cells[itemCount + rowOffset, CostOfSalesAmountColIndex] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(TotalCostOfSalesAmount / itemCount); } if (chkProfitMargin.Checked) { cell = ws.Cells[itemCount + rowOffset, ProfitMarginColIndex] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.FormatPercent(TotalProfitMargin / itemCount); } if (chkGrossProfit.Checked) { cell = ws.Cells[itemCount + rowOffset, GrossProfitColIndex] as Excel.Range; cell.Value2 = _obj.CurrencyMgr.Format(TotalGrossProfit / itemCount); } ws.UsedRange.Columns.AutoFit(); sh2.Locked = oldSh2Locked; }
/// <inheritdoc /> public override IQueryResult Execute(string expr, IEntitiesSerializer serializer) { var remark = Parsing.Token(ref expr); var rate = Parsing.DoubleF(ref expr) / 10000D; var all = Parsing.Optional(ref expr, "all"); var endDate = !all ? Parsing.UniqueTime(ref expr) : null; Parsing.Eof(expr); var loans = Accountant.RunGroupedQuery($"({MajorFilter()})-\"\" ``rtcC").Items .Cast<ISubtotalRemark>() .ToList(); var rmkObj = loans.Single( b => b.Remark?.StartsWith(remark, StringComparison.InvariantCultureIgnoreCase) == true && !b.Remark.EndsWith("-利息", StringComparison.Ordinal)); var titleObj = rmkObj.Items.Cast<ISubtotalTitle>().Single(); var cntObj = titleObj.Items.Cast<ISubtotalContent>().Single(); // ReSharper disable once PossibleInvalidOperationException var title = titleObj.Title.Value; var content = cntObj.Content; var rmk = rmkObj.Remark; var currency = cntObj.Items.Cast<ISubtotalCurrency>().Single().Currency; var info = new LoanInfo { Currency = currency, Title = title, Content = content, Remark = rmk, Rate = rate }; if (!all && !endDate.HasValue || endDate.HasValue) { // ReSharper disable once PossibleInvalidOperationException var lastD = Accountant.RunVoucherQuery(info.QueryInterest(this)) .OrderByDescending(v => v.Date, new DateComparer()) .FirstOrDefault() ?.Date ?? Accountant.RunVoucherQuery(info.QueryCapital(this)) .OrderBy(v => v.Date, new DateComparer()) .First() .Date.Value; var capQuery = $"{info.QueryCapital(this)} [~{lastD.AsDate()}]``v"; var intQuery = $"{info.QueryInterest(this)} [~{lastD.AsDate()}]``v"; var capitalIntegral = Accountant.RunGroupedQuery(capQuery).Fund; var interestIntegral = Accountant.RunGroupedQuery(intQuery).Fund; Regularize( info, ref capitalIntegral, ref interestIntegral, lastD, endDate ?? ClientDateTime.Today); } else { var capitalIntegral = 0D; var interestIntegral = 0D; Regularize( info, ref capitalIntegral, ref interestIntegral, null, ClientDateTime.Today); } return new DirtySucceed(); }
protected DistributedShell(Accountant helper) { Accountant = helper; var resetComopser = new ShellComposer { new ShellComponent( "soft", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; Parsing.Eof(expr); return(ExecuteResetSoft(dist, rng)); }), new ShellComponent( "mixed", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; Parsing.Eof(expr); return(ExcuteResetMixed(dist, rng)); }), new ShellComponent( "hard", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); var vouchers = Parsing.OptColVouchers(ref expr); Parsing.Eof(expr); return(ExecuteResetHard(dist, vouchers)); }) }; m_Composer = new ShellComposer { new ShellComponent( "all", (expr, serializer) => { var safe = Parsing.Token(ref expr, false, t => t == "unsafe") == null; var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); if (dist.IsDangerous() && safe) { throw new SecurityException("检测到弱检索式"); } return(ExecuteList(dist, null, false, serializer)); }), new ShellComponent( "li", (expr, serializer) => { var safe = Parsing.Token(ref expr, false, t => t == "unsafe") == null; var dt = Parsing.UniqueTime(ref expr) ?? ClientDateTime.Today; var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); if (dist.IsDangerous() && safe) { throw new SecurityException("检测到弱检索式"); } return(ExecuteList(dist, dt, true, serializer)); }), new ShellComponent( "q", (expr, serializer) => { var safe = Parsing.Token(ref expr, false, t => t == "unsafe") == null; var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); if (dist.IsDangerous() && safe) { throw new SecurityException("检测到弱检索式"); } return(ExecuteQuery(dist, serializer)); }), new ShellComponent( "reg", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; var vouchers = Parsing.OptColVouchers(ref expr); Parsing.Eof(expr); return(ExecuteRegister(dist, rng, vouchers, serializer)); }), new ShellComponent( "unreg", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; var vouchers = Parsing.OptColVouchers(ref expr); Parsing.Eof(expr); return(ExecuteUnregister(dist, rng, vouchers, serializer)); }), new ShellComponent( "recal", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); return(ExecuteRecal(dist, serializer)); }), new ShellComponent("rst", (expr, serializer) => resetComopser.Execute(expr, serializer)), new ShellComponent( "ap", (expr, serializer) => { var collapse = Parsing.Optional(ref expr, "col"); var dist = Parsing.DistributedQuery(ref expr); var rng = Parsing.Range(ref expr) ?? DateFilter.Unconstrained; Parsing.Eof(expr); return(ExecuteApply(dist, rng, collapse)); }), new ShellComponent( "chk", (expr, serializer) => { var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); return(ExecuteCheck(dist, new DateFilter(null, ClientDateTime.Today), serializer)); }), new ShellComponent( null, (expr, serializer) => { var dt = Parsing.UniqueTime(ref expr) ?? ClientDateTime.Today; var dist = Parsing.DistributedQuery(ref expr); Parsing.Eof(expr); return(ExecuteList(dist, dt, false, serializer)); }) }; }
public Composite(Accountant accountant) : base(accountant) { }
public Statement(Accountant accountant) : base(accountant) { }
public AssetDisposition(Accountant accountant) : base(accountant) { }
private void chkBackupItemAddOn_CheckedChanged(object sender, EventArgs e) { Accountant _obj = mApplicationController.mAccountant; _obj.ConfigMgr.SetParam("BACKUP_ITEMADDON", chkBackupItemAddOn.Checked ? "1" : "0"); }
/// <inheritdoc /> public override IQueryResult Execute(string expr, IEntitiesSerializer serializer) { var voucherID = Parsing.Token(ref expr); var guids = new List <string>(); var guidT = Guid.Empty; // ReSharper disable once AccessToModifiedClosure while (Parsing.Token(ref expr, true, s => Guid.TryParse(s, out guidT)) != null) { guids.Add(guidT.ToString()); } Parsing.Eof(expr); var voucher = Accountant.SelectVoucher(voucherID); if (voucher == null) { throw new ApplicationException("找不到记账凭证"); } var sb = new StringBuilder(); foreach (var detail in voucher.Details.Where(vd => vd.Title == 1601 || vd.Title == 1701)) { if (guids.Count != 0 && !guids.Contains(detail.Content)) { continue; } var asset = Accountant.SelectAsset(Guid.Parse(detail.Content)); foreach (var item in asset.Schedule) { if (item is DispositionItem) { throw new InvalidOperationException("已经处置"); } if (item.Date < voucher.Date) { if (item.VoucherID == null) { throw new InvalidOperationException("尚未注册"); } } else { if (item.VoucherID != null) { throw new InvalidOperationException("注册过多"); } } } var id = asset.Schedule.FindIndex(it => it.Date >= voucher.Date); if (id != -1) { asset.Schedule.RemoveRange(id, asset.Schedule.Count - id); } asset.Schedule.Add(new DispositionItem { Date = voucher.Date, VoucherID = voucher.ID }); sb.Append(serializer.PresentAsset(asset).Wrap()); Accountant.Upsert(asset); } if (sb.Length > 0) { return(new DirtyText(sb.ToString())); } return(new PlainSucceed()); }
private void show_Click(object sender, EventArgs e) { hmssDataContext dbcon = new hmssDataContext(); Admin pro1 = new Admin(); Receptionist pro3 = new Receptionist(); Employee pro4 = new Employee(); Doctor pro5 = new Doctor(); pro1 = dbcon.Admins.SingleOrDefault(x => x.LoginID == holdID); pro5 = dbcon.Doctors.SingleOrDefault(x => x.LoginID == holdID); pro3 = dbcon.Receptionists.SingleOrDefault(x => x.LoginID == holdID); pro4 = dbcon.Employees.SingleOrDefault(x => x.LoginID == holdID); MessageBox.Show(holdID, holdProfile); if (pro1.LoginID == holdID && holdProfile == "ADMIN") { if (pro1 != null) { MessageBox.Show("NOT NULL ADMIN"); metroTextBox1.Text = pro1.AdminName; metroTextBox2.Text = "N/A"; metroTextBox3.Text = "N/A"; metroTextBox4.Text = "N/A"; metroTextBox5.Text = pro1.AdminPhone; metroTextBox6.Text = "N/A"; } else { MessageBox.Show(" NULL ADMIN"); MetroMessageBox.Show(this, "Incorrect Data.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } Patient pro2 = new Patient(); pro2 = dbcon.Patients.SingleOrDefault(x => x.LoginID == holdID); if (pro2.LoginID == holdID && holdProfile == "PATIENT") { if (pro2 != null) { MessageBox.Show("NOT NULL"); metroTextBox1.Text = pro2.PatientName; metroTextBox2.Text = pro2.PatientAge; metroTextBox3.Text = pro2.PatientGender; metroTextBox4.Text = pro2.PatientAddress; metroTextBox5.Text = pro2.PatientPhone; metroTextBox6.Text = "N/A"; } else { MessageBox.Show("NULL"); MetroMessageBox.Show(this, "NULL DATABASE.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } Accountant pro6 = new Accountant(); pro6 = dbcon.Accountants.SingleOrDefault(x => x.LoginID == holdID); if (pro6.AccountantID == holdID && holdProfile == "ACCOUNTANT") { MessageBox.Show(holdProfile); if (pro6 != null) { metroTextBox1.Text = pro6.AccountantName; metroTextBox2.Text = pro6.AccountantAge; metroTextBox3.Text = pro6.AccountantGender; metroTextBox4.Text = pro6.AccountantAddress; metroTextBox5.Text = pro6.AccountantPhone; metroTextBox6.Text = pro6.AccountantEmail; } else { MetroMessageBox.Show(this, "Incorrect Data.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } if (pro5.LoginID == holdID && holdProfile == "DOCTOR") { if (pro5 != null) { metroTextBox1.Text = pro5.DoctorName; metroTextBox2.Text = pro5.DoctorAge; metroTextBox3.Text = pro5.DoctorGender; metroTextBox4.Text = pro5.DoctorAddress; metroTextBox5.Text = pro5.DoctorPhone; metroTextBox6.Text = pro5.DoctorEmail; } else { MetroMessageBox.Show(this, "Incorrect Data.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } else if (pro3.LoginID == holdID && holdProfile == "RECEPTIONIST") { if (pro3 != null) { metroTextBox1.Text = pro3.ReceptionistName; metroTextBox2.Text = pro3.ReceptionistAge; metroTextBox3.Text = pro3.ReceptionistGender; metroTextBox4.Text = pro3.ReceptionistAddress; metroTextBox5.Text = pro3.ReceptionistPhone; metroTextBox6.Text = pro3.ReceptionistEmail; } else { MetroMessageBox.Show(this, "Incorrect Data.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } else if (pro4.LoginID == holdID && holdProfile == "Employee") { if (pro4 != null) { metroTextBox1.Text = pro4.EmployeeName; metroTextBox2.Text = pro4.EmployeeAge; metroTextBox3.Text = pro4.EmployeeGender; metroTextBox4.Text = pro4.EmployeeAddress; metroTextBox5.Text = pro4.EmployeePhone; metroTextBox6.Text = pro4.EmployeeEmail; } else { MetroMessageBox.Show(this, "Incorrect Data.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } } }
public BOListLocation(Accountant accountant) : base(accountant) { mObjectID = BOType.BOListLocation; }