示例#1
0
        public GoodTypeForm(GoodType goodType)
        {
            InitializeComponent();

            GoodType = goodType;
            fillGood(goodType);
        }
        public async void Init(GoodType goodType)
        {
            scope = new DbScope();
            goods = await InvoiceCore.Instance.GetGoodsAsync(scope);
            cmbGoodType.DataSource = goods.Select(g => g.Name).ToList();
            cmbGoodType.SelectedItem = goodType.Name;

            await RebindGridAsync(goodType);

            cmbGoodType.SelectedIndexChanged += CmbGoodType_SelectedIndexChanged;
        }
示例#3
0
        private IEnumerable<SaleParsed> ParseGoodSale(ISheet sheet, GoodType good, DateTime dateTime, int customerColumn, int startRow)
        {
            var sales = new List<SaleParsed>();

            for (int r = startRow; ; r++)
            {
                var row = sheet.GetRow(r);
                if (row == null)
                    break;

                var customerCell = row.GetCell(customerColumn);
                if (customerCell == null || string.IsNullOrWhiteSpace(customerCell.StringCellValue))
                    break;

                var customer = customerCell.StringCellValue.Trim();

                int qty = 0, ret = 0;
                var qtyCell = sheet.GetRow(r).GetCell(good.ColumnInDocument - 1);
                if (qtyCell != null && qtyCell.CellType == CellType.Numeric
                    && qtyCell.NumericCellValue > 0)
                {
                    qty = (int)qtyCell.NumericCellValue;
                }

                if (good.HasReturn)
                {
                    var retCell = sheet.GetRow(r).GetCell(good.ReturnColumn.Value - 1);
                    if (retCell != null && retCell.CellType == CellType.Numeric
                        && retCell.NumericCellValue > 0)
                    {
                        ret = (int)retCell.NumericCellValue;
                    }
                }

                if (qty > 0 && qty > ret)
                {
                    var sale = new SaleParsed();
                    sale.GoodType = good;
                    sale.DateTime = dateTime;
                    sale.Customer = customer;
                    sale.Producer = producer;
                    sale.Quantity = qty;
                    sale.Return = ret;
                    sales.Add(sale);
                }
            }

            return sales;
        }
        private async Task RebindGridAsync(GoodType goodType)
        {
            specialPrices = await InvoiceCore.Instance.GetSpecialPricesAsync(scope);
            var source = specialPrices.ToList().Where(p => p.GoodTypeId == goodType.Id);

            dataGridView1.AutoGenerateColumns = false;
            ColumnPrice.DataPropertyName = "Price";
            СolumnClinetName.DataPropertyName = "CustomerName";
            dataGridView1.DataSource = source.ToList();

            var clients = InvoiceCore.Instance.GetCustomers(scope);
            cmbClient.DataSource = clients
                .Where(c => !source.Any(sp => sp.Customer.Name == c.Name))
                .Select(c => c.Name).ToList();
        }
示例#5
0
        private void fillGood(GoodType goodType)
        {
            txtColumn.Text = goodType.ColumnName;
            txtPrice.Text = goodType.Price.ToString();
            txtTitle.Text = goodType.Name;

            if (goodType.HasReturn)
            {
                checkBox1.Checked = true;
                txtReturnColumn.Text = goodType.ReturnColumnName;
            }
            else
            {
                checkBox1.Checked = false;
            }
        }
示例#6
0
        private bool buildGood()
        {
            try
            {
                if (GoodType == null)
                    GoodType = new GoodType();

                txtPrice.Text = txtPrice.Text.Replace(",", System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                txtPrice.Text = txtPrice.Text.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                GoodType.Name = txtTitle.Text;
                GoodType.Price = double.Parse(txtPrice.Text.Trim());
                GoodType.ColumnName = txtColumn.Text.Trim();
                GoodType.ReturnColumnName = txtReturnColumn.Text.Trim();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }

            return true;
        }
示例#7
0
 public void AddSpecialPrice(DbScope scope, GoodType good, Customer client, double price)
 {
     scope.DataProvider.AddSpecialPrice(good, client, price);
 }
示例#8
0
 public void RemoveGoodType(DbScope scope, GoodType good)
 {
     scope.DataProvider.Remove(good);
 }
示例#9
0
 public void SaveGoodType(DbScope scope, GoodType goodType)
 {
     scope.DataProvider.SaveEntity(goodType);
 }
示例#10
0
        public void StartAutoUpdating(GoodType goodType, string filePath, string producer)
        {
            //var updater = new AutoDBUpdater(goodType, filePath, producer);

            //var updateCheck = updater.ChechFileModified(Settings.ExcellFilePath, Settings.LastExcellFileHash);

            //if (updateCheck.Item1)
            //    FileChanged(goodType, filePath); 

            //updater.FileChanged = (path) =>
            //{
            //    Settings.LastExcellFileHash = updateCheck.Item2;
            //    ImportSalesFromXLS(path, goodType, producer, true);
            //    FileChanged(goodType, filePath);
            //};

            //updater.FileRenamed = (path) =>
            //{
            //    Settings.ExcellFilePath = path;
            //    Settings.LastExcellFileHash = updateCheck.Item2;
            //    FileRenamed(goodType, filePath, path);
            //};

            //updater.StartWatchingFile();
        }
示例#11
0
 public AutoDBUpdater(GoodType goodType, string filePath, string producer)
 {
     this.GoodType = goodType;
     this.filePath = filePath;
     this.producer = producer;
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SoldItem"/> class.
 /// </summary>
 /// <param name="goodType">Type of the good.</param>
 /// <param name="qty">The qty.</param>
 /// <param name="price">The custom price.</param>
 public SoldItem(GoodType goodType, int qty, double? price = null)
 {
     GoodType = goodType;
     Qty = qty;
     Price = price ?? goodType.Price;
 }
        public Dictionary<DateTime, IEnumerable<SaleParsed>> ImportFromFile(string fileName, GoodType type, string producer)
        {
            var result = new Dictionary<DateTime, IEnumerable<SaleParsed>>();

            var feed = GetSpreadSheetsFeed();

            var mySpreadsheet = (SpreadsheetEntry)feed.Entries.FirstOrDefault(e => e.Title.Text.Equals(fileName, StringComparison.InvariantCultureIgnoreCase));
            if (mySpreadsheet == null)
                throw new FileNotFoundException(fileName);

            //retrieve the worksheets of a particular spreadsheet
            var link = mySpreadsheet.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            var wQuery = new WorksheetQuery(link.HRef.ToString());
            var wFeed = spreadsheetsService.Query(wQuery);
            //retrieve the cells in a worksheet
            //var worksheetEntry = (WorksheetEntry)wFeed.Entries[0];

            foreach (var wSheetAtomEntry in wFeed.Entries)
            {
                var wSheet = (WorksheetEntry)wSheetAtomEntry;
                var cLink = wSheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
                var cQuery = new CellQuery(cLink.HRef.ToString());
                var cFeed = spreadsheetsService.Query(cQuery);

                foreach (var cellAtomEntryEntry in cFeed.Entries)
                {
                    var cCell = (CellEntry) cellAtomEntryEntry;
                    Console.WriteLine("Value on row {0} and column {1} is {2}", cCell.Cell.Row,
                        cCell.Cell.Column, cCell.Cell.Value);
                }
            }

            //using (var fs = File.OpenRead(fileName))
            //{
            //    var workbook = new SpreadsheetEntry();

            //    for (var sheetIdx = 0; sheetIdx < workbook.NumberOfSheets; sheetIdx++)
            //    {

            //        ISheet sheet = workbook.GetSheetAt(sheetIdx);

            //        var datesRow = sheet.GetRow(Settings.DatesRow);

            //        if (datesRow == null)
            //            continue;

            //        var datesCell = datesRow.GetCell(Settings.DatesColumn);

            //        if (datesCell == null)
            //            continue;

            //        DateTime startDate = GetStartDate(datesCell);

            //        var sales = ParseSales(sheet, datesCell, startDate, type, producer);
            //        foreach (var s in sales)
            //            result.Add(s.Key, s.Value);
            //    }
            //}

            return result;
        }