├── .gitignore ├── FprnM1C.dll ├── favicon.ico ├── favicon (1).ico ├── Resources └── placeholder.bmp ├── drivers ├── FiscalAbstractFabricInterface.cs ├── FiscalAbstractFabric.cs ├── FiscalInterface.cs ├── PiritLib.cs ├── VikiPrint.cs └── Atol.cs ├── tools ├── CartProvider.cs ├── OrderProvider.cs ├── ClientProvider.cs ├── CashierProvider.cs ├── CategoryProvider.cs ├── DiscountProvider.cs ├── ProductProvider.cs ├── OrderElementProvider.cs └── Connverter.cs ├── services ├── actions │ ├── RequestAction.cs │ ├── AnnulateAction.cs │ ├── SetCashierAction.cs │ └── PurchaseAction.cs ├── Database.cs ├── Rounder.cs ├── WebServer.cs ├── Fiscal.cs └── DataMapper.cs ├── Readme.md ├── entities ├── interfaces │ └── CartElement.cs ├── Cashbox.cs ├── Cashier.cs ├── Category.cs ├── Client.cs ├── Discount.cs ├── OrderElement.cs ├── Order.cs └── Product.cs ├── Program.cs ├── DvizhSeller.csproj.user ├── Properties ├── DataSources │ ├── DvizhSeller.repositories.Cart.datasource │ ├── DvizhSeller.tools.CartData.datasource │ ├── DvizhSeller.tools.OrderProvider.datasource │ ├── DvizhSeller.tools.CategoryProvider.datasource │ ├── DvizhSeller.tools.DisountProvider.datasource │ └── DvizhSeller.tools.OrderElementProvider.datasource ├── AssemblyInfo.cs ├── Settings.settings ├── Resources.Designer.cs └── Resources.resx ├── TabletForm.cs ├── packages.config ├── DataExchangeForm.cs ├── BarcodeScanerForm.cs ├── repositories ├── Cashbox.cs ├── Category.cs ├── Client.cs ├── Discount.cs ├── Cashier.cs ├── Cart.cs ├── Order.cs └── Product.cs ├── FiscalTestForm.cs ├── AboutForm.cs ├── FreeSaleForm.cs ├── CashierChooseForm.cs ├── DiscountsBookForm.cs ├── ClientsBookForm.cs ├── ClientChooseForm.cs ├── BarcodeScanerForm.Designer.cs ├── OrdersForm.cs ├── DataExchangeForm.Designer.cs ├── TabletForm.Designer.cs ├── CashiersBookForm.cs ├── CashierChooseForm.Designer.cs ├── App.config ├── ClientChooseForm.Designer.cs ├── FiscalTestForm.Designer.cs ├── ShopBookForm.cs ├── FreeSaleForm.Designer.cs ├── SettingsForm.cs ├── AboutForm.Designer.cs ├── ClientsBookForm.Designer.cs └── DiscountsBookForm.Designer.cs /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj 3 | /*.resx 4 | /*.csproj -------------------------------------------------------------------------------- /FprnM1C.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pistol88/dvizh-seller/HEAD/FprnM1C.dll -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pistol88/dvizh-seller/HEAD/favicon.ico -------------------------------------------------------------------------------- /favicon (1).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pistol88/dvizh-seller/HEAD/favicon (1).ico -------------------------------------------------------------------------------- /Resources/placeholder.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pistol88/dvizh-seller/HEAD/Resources/placeholder.bmp -------------------------------------------------------------------------------- /drivers/FiscalAbstractFabricInterface.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller.drivers 2 | { 3 | public interface FiscalAbstractFabricInterface 4 | { 5 | FiscalInterface Build(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tools/CartProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class CartProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/OrderProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class OrderProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/ClientProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class ClientProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/CashierProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class CashierProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/CategoryProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class CategoryProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/DiscountProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class DisountProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/ProductProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class ProductProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/OrderElementProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel; 7 | 8 | namespace DvizhSeller.tools 9 | { 10 | class OrderElementProvider : BindingList 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /services/actions/RequestAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.services.actions 8 | { 9 | public class RequestAction 10 | { 11 | public string jsonrpc { get; set; } 12 | public string method { get; set; } 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | Внимание: проект в архиве с 2018 года, не обновляется. 2 | 3 | Рабочее место кассира (АРМ) для предприятий мелкой розничной торговли. Синхронизируется с dvizh.net 4 | 5 | * [Скачать и установить](http://dvizh.net/files/dvizh.arm.cashier.setup.exe) 6 | * [Файлы проекта Visual Studio](https://www.dropbox.com/sh/f2tm57j80e8h13x/AAAstATnZM1lsKFbNnzz8IzOa?dl=0) 7 | * [Инструкция по установке](http://dvizh.net/config?id=1) 8 | 9 | ![dvizh.arm.cashier](http://dvizh.net/images/Dvizh.Cashier.png) 10 | -------------------------------------------------------------------------------- /entities/interfaces/CartElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities.interfaces 8 | { 9 | public interface CartElement 10 | { 11 | int GetCartCount(); 12 | 13 | int GetId(); 14 | 15 | void SetCartCount(int count); 16 | 17 | double GetPrice(); 18 | 19 | string GetName(); 20 | 21 | string GetNameAndSku(); 22 | 23 | int GetCategoryId(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /services/actions/AnnulateAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.services.actions 8 | { 9 | public class AnnulateAction 10 | { 11 | public string jsonrpc { get; set; } 12 | public string method { get; set; } 13 | public AnnulateParams _params { get; set; } 14 | } 15 | 16 | public class AnnulateParams 17 | { 18 | public entities.OrderElement[] elements { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /services/actions/SetCashierAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.services.actions 8 | { 9 | 10 | public class SetCashierAction 11 | { 12 | public string jsonrpc { get; set; } 13 | public string method { get; set; } 14 | public SetCashierParams _params { get; set; } 15 | } 16 | 17 | public class SetCashierParams 18 | { 19 | public int id { get; set; } 20 | public string name { get; set; } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace DvizhSeller 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// Главная точка входа для приложения. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new CashierForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /drivers/FiscalAbstractFabric.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.drivers 8 | { 9 | public class FiscalAbstractFabric : FiscalAbstractFabricInterface 10 | { 11 | public FiscalInterface Build() 12 | { 13 | if(Properties.Settings.Default.fiscalDriverType == 0) 14 | { 15 | return new VikiPrint(Properties.Settings.Default.fiscalComPort, 57600); 16 | } 17 | 18 | return new Atol(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DvizhSeller.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | ru-RU 11 | false 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /entities/Cashbox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | class Cashbox 10 | { 11 | int id; 12 | string name; 13 | 14 | public Cashbox(int setId, string setName) 15 | { 16 | id = setId; 17 | name = setName; 18 | } 19 | 20 | public string GetName() 21 | { 22 | return name; 23 | } 24 | 25 | public int GetId() 26 | { 27 | return id; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.repositories.Cart.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.repositories.Cart, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.tools.CartData.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.tools.CartData, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.tools.OrderProvider.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.tools.OrderProvider, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.tools.CategoryProvider.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.tools.CategoryProvider, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.tools.DisountProvider.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.tools.DisountProvider, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /Properties/DataSources/DvizhSeller.tools.OrderElementProvider.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | DvizhSeller.tools.OrderElementProvider, DvizhSeller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /TabletForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class TabletForm : Form 14 | { 15 | CashierForm cashierForm; 16 | 17 | public TabletForm(CashierForm setCashierForm) 18 | { 19 | cashierForm = setCashierForm; 20 | InitializeComponent(); 21 | } 22 | 23 | private void TabletForm_Load(object sender, EventArgs e) 24 | { 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tools/Connverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.tools 8 | { 9 | class Connverter 10 | { 11 | public static String ToUTF8(string input) 12 | { 13 | Encoding ecdng = Encoding.Default; 14 | 15 | byte[] bts = ecdng.GetBytes(input); 16 | ecdng = Encoding.UTF8; 17 | 18 | return ecdng.GetString(bts, 0, bts.Length); 19 | } 20 | 21 | public static String FromUTF8(string input) 22 | { 23 | Encoding ecdng = Encoding.UTF8; 24 | 25 | byte[] bts = ecdng.GetBytes(input); 26 | ecdng = Encoding.Default; 27 | 28 | return ecdng.GetString(bts, 0, bts.Length); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /entities/Cashier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | class Cashier 10 | { 11 | int id; 12 | string name; 13 | 14 | public Cashier(int setId, string setName) 15 | { 16 | id = setId; 17 | name = setName; 18 | } 19 | 20 | public string Name 21 | { 22 | get { return name; } 23 | set { name = value; } 24 | } 25 | 26 | public string GetName() 27 | { 28 | return name; 29 | } 30 | 31 | public int GetId() 32 | { 33 | return id; 34 | } 35 | 36 | public void SetName(string setName) 37 | { 38 | name = setName; 39 | } 40 | 41 | public void SetId(int setId) 42 | { 43 | id = setId; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /services/Database.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | using System.IO; 8 | using System.Windows.Forms; 9 | 10 | namespace DvizhSeller.services 11 | { 12 | class Database 13 | { 14 | string dbConnectionString; 15 | string dbFile = Properties.Settings.Default.dbFile; 16 | public SQLiteConnection connection; 17 | 18 | public Database() 19 | { 20 | if (!File.Exists(dbFile)) 21 | { 22 | dbConnectionString = "Data Source=database.db; Version=3;"; 23 | MessageBox.Show("База данных не найдена, проверьте настройки. Подключена временная БД, доступная только для чтения."); 24 | } 25 | else 26 | dbConnectionString = "Data Source=" + dbFile + "; Version=3;"; 27 | 28 | connection = new SQLiteConnection(dbConnectionString); 29 | connection.Open(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DataExchangeForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class DataExchangeForm : Form 14 | { 15 | public DataExchangeForm() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void DataExchangeForm_Load(object sender, EventArgs e) 21 | { 22 | 23 | } 24 | 25 | public void Step() 26 | { 27 | totalProgressBar.Value++; 28 | } 29 | 30 | public void SetMessage(string message) 31 | { 32 | messageBox.Visible = true; 33 | messageBox.Text = message; 34 | } 35 | 36 | public void SetMessage2(string message) 37 | { 38 | messageBox2.Visible = true; 39 | messageBox2.Text = message; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /services/Rounder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.services 8 | { 9 | class Rounder 10 | { 11 | public double Round(double num) 12 | { 13 | switch(Properties.Settings.Default.roundingType) 14 | { 15 | case 0: 16 | return Math.Round(num, Properties.Settings.Default.rounding); 17 | case 1: //До 1 18 | return Math.Round(num); 19 | case 2: //до 5 20 | return RoundFive(num); 21 | case 3: //до 10 22 | return Math.Round(Math.Round(num / 10) * 10); 23 | } 24 | 25 | return num; 26 | } 27 | 28 | public static int RoundFive(double d) 29 | { 30 | if (d % 5 > 2.5) 31 | return (int)(d / 5) * 5 + 5; 32 | else 33 | return (int)(d / 5) * 5; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BarcodeScanerForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class BarcodeScanerForm : Form 14 | { 15 | CashierForm cashierForm; 16 | 17 | public BarcodeScanerForm(CashierForm setCashierForm) 18 | { 19 | cashierForm = setCashierForm; 20 | 21 | InitializeComponent(); 22 | } 23 | 24 | private void BarcodeScanerForm_Load(object sender, EventArgs e) 25 | { 26 | barCodeBox.Select(); 27 | } 28 | 29 | private void barCodeBox_KeyDown(object sender, KeyEventArgs e) 30 | { 31 | String barCodeStr = barCodeBox.Text; 32 | 33 | if (e.KeyCode == Keys.Enter) 34 | { 35 | cashierForm.BuyBySku(barCodeStr); 36 | barCodeBox.Text = ""; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /repositories/Cashbox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.repositories 8 | { 9 | class Cashbox 10 | { 11 | private List cashboxes = new List(); 12 | 13 | services.Database db; 14 | 15 | public Cashbox(services.Database setDb) 16 | { 17 | db = setDb; 18 | } 19 | 20 | public void Add(entities.Cashbox cashbox) 21 | { 22 | cashboxes.Add(cashbox); 23 | } 24 | 25 | public void Delete(entities.Cashbox cashbox) 26 | { 27 | cashboxes.Remove(cashbox); 28 | } 29 | 30 | public List GetList() 31 | { 32 | return cashboxes; 33 | } 34 | 35 | public entities.Cashbox FindOne(int id) 36 | { 37 | return cashboxes.Find(x => x.GetId() == id); 38 | } 39 | 40 | public List FindByName(string name) 41 | { 42 | return cashboxes.FindAll(x => x.GetName().Contains(name)); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /entities/Category.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | public class Category 10 | { 11 | int id; 12 | string name; 13 | int parent_id; 14 | 15 | public Category(int setId, string setName) 16 | { 17 | id = setId; 18 | name = setName; 19 | } 20 | 21 | public string Name 22 | { 23 | get { return name; } 24 | set { name = value; } 25 | } 26 | 27 | public string GetName() 28 | { 29 | return name; 30 | } 31 | 32 | public int GetId() 33 | { 34 | return id; 35 | } 36 | 37 | public int GetParentId() 38 | { 39 | return parent_id; 40 | } 41 | 42 | public void SetParentId(int setParent_id) 43 | { 44 | parent_id = setParent_id; 45 | } 46 | 47 | public void SetId(int setId) 48 | { 49 | id = setId; 50 | } 51 | 52 | public void SetName(string setName) 53 | { 54 | name = setName; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /drivers/FiscalInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.drivers 8 | { 9 | public interface FiscalInterface 10 | { 11 | void OpenDocument(byte type); 12 | 13 | void CloseDocument(); 14 | 15 | void SetTaxNumber(byte number); 16 | 17 | void SetCashierName(string name); 18 | 19 | void SetNumDepart(byte number); 20 | 21 | void SetDocNumber(int number); 22 | 23 | void ScrollPaper(); 24 | 25 | void PrintString(string text); 26 | 27 | void RegisterProduct(string name, string barcode, double quantity, double price, int numPos = 1); 28 | 29 | void RegisterPayment(double sum, byte type = 0); 30 | 31 | void RegisterDiscount(byte type, string nameDiscount, int sum); 32 | 33 | void PrintTotal(); 34 | 35 | void PrintServiceData(); 36 | 37 | bool Ready(); 38 | 39 | bool IsSessionOpen(); 40 | 41 | void OpenSession(); 42 | 43 | void AnnulateProduct(string name, double quantity, double price); 44 | 45 | void Storning(string name, double quantity, double price); 46 | 47 | void CloseSession(); 48 | 49 | List GetStatuses(); 50 | 51 | void BotIndent(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /FiscalTestForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class FiscalTestForm : Form 14 | { 15 | services.Fiscal fiscal; 16 | 17 | public FiscalTestForm() 18 | { 19 | fiscal = new services.Fiscal(new drivers.FiscalAbstractFabric()); 20 | 21 | InitializeComponent(); 22 | 23 | labelStatus.Text = fiscal.GetStatus().ToString(); 24 | } 25 | 26 | private void FiscalTestForm_Load(object sender, EventArgs e) 27 | { 28 | 29 | } 30 | 31 | private void printText_Click(object sender, EventArgs e) 32 | { 33 | fiscal.TestPrint(); 34 | labelStatus.Text = fiscal.GetStatus().ToString(); 35 | } 36 | 37 | private void button1_Click(object sender, EventArgs e) 38 | { 39 | fiscal.TestPrint(); 40 | labelStatus.Text = fiscal.GetStatus().ToString(); 41 | } 42 | 43 | private void button2_Click(object sender, EventArgs e) 44 | { 45 | fiscal.TestPrint(); 46 | labelStatus.Text = fiscal.GetStatus().ToString(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /AboutForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Diagnostics; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class AboutForm : Form 14 | { 15 | services.Fiscal fiscal = new services.Fiscal(new drivers.FiscalAbstractFabric()); 16 | 17 | public AboutForm() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void AboutForm_Load(object sender, EventArgs e) 23 | { 24 | LinkLabel.Link link = new LinkLabel.Link(); 25 | link.LinkData = "http://dvizh.net/"; 26 | dvizhLink.Links.Add(link); 27 | 28 | LinkLabel.Link link2 = new LinkLabel.Link(); 29 | link2.LinkData = "mailto:admin@nethammer.ru"; 30 | montanaMail.Links.Add(link2); 31 | } 32 | 33 | private void dvizhLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 34 | { 35 | Process.Start(e.Link.LinkData as string); 36 | } 37 | 38 | private void montanaMail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 39 | { 40 | Process.Start(e.Link.LinkData as string); 41 | } 42 | 43 | private void pictureBox1_Click(object sender, EventArgs e) 44 | { 45 | fiscal.March(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /FreeSaleForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class FreeSaleForm : Form 14 | { 15 | public CashierForm cashierForm; 16 | 17 | public FreeSaleForm(CashierForm setCashierForm) 18 | { 19 | cashierForm = setCashierForm; 20 | InitializeComponent(); 21 | } 22 | 23 | private void FreeSaleForm_Load(object sender, EventArgs e) 24 | { 25 | priceBox.Select(); 26 | priceBox.Focus(); 27 | } 28 | 29 | private void FreeSaleForm_KeyDown(object sender, KeyEventArgs e) 30 | { 31 | if (e.KeyCode == Keys.Enter) 32 | { 33 | string productName = nameBox.Text; 34 | double productPrice = Convert.ToDouble(priceBox.Text); 35 | int count = Convert.ToInt16(productCount.Value); 36 | entities.Product product = new entities.Product(0, "0", productName, productPrice); 37 | 38 | cashierForm.PutToCart(product, count); 39 | productCount.Value = 1; 40 | nameBox.Text = "Товар X"; 41 | priceBox.Text = ""; 42 | 43 | 44 | cashierForm.BarCodeFocus(); 45 | 46 | this.Close(); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Общие сведения об этой сборке предоставляются следующим набором 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("DvizhSeller")] 9 | [assembly: AssemblyDescription("АРМ кассира")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Движ")] 12 | [assembly: AssemblyProduct("DvizhSeller")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 18 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(true)] 21 | 22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 23 | [assembly: Guid("73e44830-4927-4d9f-9205-730b7d64c3ff")] 24 | 25 | // Сведения о версии сборки состоят из следующих четырех значений: 26 | // 27 | // Основной номер версии 28 | // Дополнительный номер версии 29 | // Номер сборки 30 | // Редакция 31 | // 32 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 33 | // используя "*", как показано ниже: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /entities/Client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | class Client 10 | { 11 | int id; 12 | string name; 13 | string phone; 14 | 15 | public Client(int setId, string setName, string setPhone) 16 | { 17 | id = setId; 18 | name = setName; 19 | phone = setPhone; 20 | } 21 | 22 | public string Name 23 | { 24 | get { return name; } 25 | set 26 | { 27 | name = value; 28 | } 29 | } 30 | 31 | public string Phone 32 | { 33 | get { return phone; } 34 | set { phone = value; } 35 | } 36 | 37 | public string GetName() 38 | { 39 | return name; 40 | } 41 | 42 | public string GetPhone() 43 | { 44 | return phone; 45 | } 46 | 47 | public int GetId() 48 | { 49 | return id; 50 | } 51 | 52 | public void SetName(string setName) 53 | { 54 | name = setName; 55 | } 56 | 57 | public void SetPhone(string setPhone) 58 | { 59 | phone = setPhone; 60 | } 61 | 62 | public void SetId(int setId) 63 | { 64 | id = setId; 65 | } 66 | 67 | public string GetNameAndPhone() 68 | { 69 | return name + phone; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /entities/Discount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | public class Discount 10 | { 11 | int id; 12 | int discount; 13 | string code; 14 | byte type; 15 | 16 | public Discount(int setId, string setCode, int setDiscount) 17 | { 18 | id = setId; 19 | code = setCode; 20 | discount = setDiscount; 21 | } 22 | 23 | public string Code 24 | { 25 | get { return code; } 26 | set 27 | { 28 | code = value; 29 | } 30 | } 31 | 32 | public int DiscountVal 33 | { 34 | get { return discount; } 35 | set { discount = value; } 36 | } 37 | 38 | public string GetName() 39 | { 40 | return code; 41 | } 42 | 43 | public string GetCode() 44 | { 45 | return code; 46 | } 47 | 48 | public int GetDiscount() 49 | { 50 | return discount; 51 | } 52 | 53 | public int GetId() 54 | { 55 | return id; 56 | } 57 | 58 | public void SetCode(string setCode) 59 | { 60 | code = setCode; 61 | } 62 | 63 | public void SetType(byte setType) 64 | { 65 | type = setType; 66 | } 67 | 68 | public void SetDiscount(int setDiscount) 69 | { 70 | discount = setDiscount; 71 | } 72 | 73 | public void SetId(int setId) 74 | { 75 | id = setId; 76 | } 77 | 78 | public byte GetType() 79 | { 80 | return type; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /services/actions/PurchaseAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.services.actions 8 | { 9 | 10 | public class PurchaseAction 11 | { 12 | public string jsonrpc { get; set; } 13 | public string method { get; set; } 14 | public PurchaseParams _params { get; set; } 15 | 16 | services.Fiscal fiscal; 17 | 18 | public void purchase() 19 | { 20 | repositories.Cart cart = new repositories.Cart(); 21 | if (this._params.discount > 0) 22 | { 23 | entities.Discount discount = new entities.Discount(1, "disc", this._params.discount); 24 | discount.SetType(this._params.discount_type); 25 | cart.SetDiscount(discount); 26 | } 27 | foreach (var product in this._params.elements) 28 | { 29 | cart.Put(product,product.CartCount); 30 | } 31 | Properties.Settings.Default.taxType = this._params.tax_id; 32 | fiscal = new services.Fiscal(new drivers.FiscalAbstractFabric(), cart); 33 | fiscal.SetTax(this._params.tax_id); 34 | fiscal.Register(this._params.payment_type); 35 | } 36 | } 37 | 38 | public class PurchaseParams 39 | { 40 | public byte payment_type { get; set; } 41 | public int discount { get; set; } 42 | public byte discount_type { get; set; } 43 | public byte tax_id { get; set; } 44 | public entities.Product[] elements { get; set; } 45 | 46 | public int GetPayment() 47 | { 48 | return payment_type; 49 | } 50 | 51 | public int GetDiscount() 52 | { 53 | return discount; 54 | } 55 | 56 | public int GetTax() 57 | { 58 | return tax_id; 59 | } 60 | } 61 | 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /CashierChooseForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class CashierChooseForm : Form 14 | { 15 | services.Database db = new services.Database(); 16 | 17 | repositories.Cashier cashiers; 18 | services.DataMapper dataMapper; 19 | 20 | CashierForm cashierForm; 21 | 22 | public CashierChooseForm(CashierForm setCashierForm) 23 | { 24 | cashierForm = setCashierForm; 25 | 26 | cashiers = new repositories.Cashier(db); 27 | 28 | dataMapper = new services.DataMapper(db); 29 | dataMapper.FillCashiers(cashiers); 30 | 31 | InitializeComponent(); 32 | } 33 | 34 | private void CashierChooseForm_Load(object sender, EventArgs e) 35 | { 36 | foreach(entities.Cashier cashier in cashiers.GetList()) 37 | { 38 | Item item = new Item(cashier.GetName(), cashier.GetId()); 39 | 40 | cashiersList.Items.Add(item); 41 | 42 | cashiersList.SelectedItem = item; 43 | } 44 | } 45 | 46 | private class Item 47 | { 48 | public string Name; 49 | public int Value; 50 | 51 | public Item(string name, int value) 52 | { 53 | Name = name; Value = value; 54 | } 55 | 56 | public override string ToString() 57 | { 58 | return Name; 59 | } 60 | 61 | public override int GetHashCode() 62 | { 63 | return Value; 64 | } 65 | } 66 | 67 | private void chooseButton_Click(object sender, EventArgs e) 68 | { 69 | cashierForm.ChooseCashier(cashiersList.SelectedItem.GetHashCode(), cashiersList.SelectedItem.ToString()); 70 | 71 | this.Close(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /entities/OrderElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | public class OrderElement 10 | { 11 | int id; 12 | int productId; 13 | string productName; 14 | double price; 15 | int count; 16 | string cancel_at; 17 | 18 | public OrderElement(int setId, int setProductId, string setProductName, double setPrice, int setCount, string setCancelAt) 19 | { 20 | id = setId; 21 | productId = setProductId; 22 | productName = setProductName; 23 | price = setPrice; 24 | count = setCount; 25 | cancel_at = setCancelAt; 26 | } 27 | 28 | public int Id 29 | { 30 | get { return id; } 31 | set { id = value; } 32 | } 33 | 34 | public string ProductName 35 | { 36 | get { return productName; } 37 | set { productName = value; } 38 | } 39 | 40 | public string CancelAt 41 | { 42 | get { return cancel_at; } 43 | set { cancel_at = value; } 44 | } 45 | 46 | public int Count 47 | { 48 | get { return count; } 49 | set { count = value; } 50 | } 51 | 52 | public double Price 53 | { 54 | get { return price; } 55 | set { price = value; } 56 | } 57 | 58 | public int GetProductId() 59 | { 60 | return productId; 61 | } 62 | 63 | public string GetProductName() 64 | { 65 | return productName; 66 | } 67 | 68 | public int GetId() 69 | { 70 | return id; 71 | } 72 | 73 | public double GetPrice() 74 | { 75 | return price; 76 | } 77 | 78 | public int GetCount() 79 | { 80 | return count; 81 | } 82 | 83 | public void SetCancelAt(string date) 84 | { 85 | cancel_at = date; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /repositories/Category.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | 8 | namespace DvizhSeller.repositories 9 | { 10 | class Category 11 | { 12 | private List categories = new List(); 13 | 14 | services.Database db; 15 | 16 | public Category(services.Database setDb) 17 | { 18 | db = setDb; 19 | } 20 | 21 | public void Add(entities.Category category) 22 | { 23 | categories.Add(category); 24 | } 25 | 26 | public int SaveWithSql(entities.Category category) 27 | { 28 | entities.Category hasCategory = FindOne(category.GetId()); 29 | 30 | SQLiteCommand command; 31 | 32 | if (hasCategory == null) 33 | { 34 | Add(category); 35 | command = new SQLiteCommand("INSERT INTO category(name, parent_id) VALUES(@name, @parent_id)", db.connection); 36 | } 37 | else 38 | { 39 | command = new SQLiteCommand("UPDATE category SET name = @name, parent_id = @parent_id WHERE id = @id ", db.connection); 40 | } 41 | 42 | command.Parameters.AddWithValue("@id", category.GetId()); 43 | command.Parameters.AddWithValue("@name", category.GetName()); 44 | command.Parameters.AddWithValue("@parent_id", category.GetParentId()); 45 | 46 | int num = command.ExecuteNonQuery(); 47 | 48 | return num; 49 | } 50 | 51 | public void Delete(entities.Category category) 52 | { 53 | categories.Remove(category); 54 | } 55 | 56 | public List GetList() 57 | { 58 | return categories; 59 | } 60 | 61 | public entities.Category FindOne(int id) 62 | { 63 | return categories.Find(x => x.GetId() == id); 64 | } 65 | 66 | public List FindByName(string name) 67 | { 68 | return categories.FindAll(x => x.GetName().Contains(name)); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DiscountsBookForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class DiscountsBookForm : Form 14 | { 15 | services.Database db = new services.Database(); 16 | 17 | tools.DisountProvider discountsProvider = new tools.DisountProvider(); 18 | tools.DisountProvider searchDiscountsProvider = new tools.DisountProvider(); 19 | 20 | repositories.Discount discounts; 21 | 22 | services.DataMapper dataMapper; 23 | 24 | public DiscountsBookForm() 25 | { 26 | InitializeComponent(); 27 | 28 | discounts = new repositories.Discount(db); 29 | 30 | dataMapper = new services.DataMapper(db); 31 | dataMapper.FillDiscounts(discounts); 32 | 33 | foreach (entities.Discount discount in discounts.GetList()) 34 | { 35 | discountsProvider.Add(discount); 36 | } 37 | 38 | discountsGridView.DataSource = discountsProvider; 39 | } 40 | 41 | private void DiscountsBookForm_Load(object sender, EventArgs e) 42 | { 43 | discountsGridView.Update(); 44 | } 45 | 46 | private void searchBox_KeyDown(object sender, KeyEventArgs e) 47 | { 48 | if (e.KeyCode == Keys.Enter) 49 | { 50 | if (searchBox.Text == "") 51 | discountsGridView.DataSource = discountsProvider; 52 | else 53 | searchDiscountsProvider = new tools.DisountProvider(); 54 | 55 | foreach (entities.Discount discount in discounts.FindByCode(searchBox.Text)) 56 | { 57 | searchDiscountsProvider.Add(discount); 58 | } 59 | 60 | discountsGridView.DataSource = searchDiscountsProvider; 61 | } 62 | } 63 | 64 | private void searchBox_Click(object sender, EventArgs e) 65 | { 66 | if (searchBox.Text == "Код") 67 | { 68 | searchBox.Text = ""; 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ClientsBookForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class ClientsBookForm : Form 14 | { 15 | services.Database db = new services.Database(); 16 | 17 | tools.ClientProvider clientsProvider = new tools.ClientProvider(); 18 | tools.ClientProvider searchClientsProvider = new tools.ClientProvider(); 19 | 20 | repositories.Client clients; 21 | 22 | services.DataMapper dataMapper; 23 | 24 | public ClientsBookForm() 25 | { 26 | InitializeComponent(); 27 | 28 | clients = new repositories.Client(db); 29 | 30 | dataMapper = new services.DataMapper(db); 31 | dataMapper.FillClients(clients); 32 | 33 | foreach (entities.Client client in clients.GetList()) 34 | { 35 | clientsProvider.Add(client); 36 | } 37 | 38 | clientsGridView.DataSource = clientsProvider; 39 | 40 | clientsGridView.Update(); 41 | } 42 | 43 | private void ClientsBookForm_Load(object sender, EventArgs e) 44 | { 45 | clientsGridView.Update(); 46 | } 47 | 48 | private void searchBox_KeyDown(object sender, KeyEventArgs e) 49 | { 50 | if (e.KeyCode == Keys.Enter) 51 | { 52 | if (searchBox.Text == "") 53 | clientsGridView.DataSource = clientsProvider; 54 | else 55 | { 56 | searchClientsProvider = new tools.ClientProvider(); 57 | 58 | foreach (entities.Client client in clients.FindByString(searchBox.Text)) 59 | { 60 | searchClientsProvider.Add(client); 61 | } 62 | 63 | clientsGridView.DataSource = searchClientsProvider; 64 | } 65 | } 66 | } 67 | 68 | private void searchBox_Click(object sender, EventArgs e) 69 | { 70 | if (searchBox.Text == "Имя или телефон") 71 | { 72 | searchBox.Text = ""; 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /repositories/Client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | using System.Windows.Forms; 8 | 9 | namespace DvizhSeller.repositories 10 | { 11 | class Client 12 | { 13 | private List clients = new List(); 14 | 15 | services.Database db; 16 | 17 | public Client(services.Database setDb) 18 | { 19 | db = setDb; 20 | } 21 | 22 | public void Add(entities.Client client) 23 | { 24 | clients.Add(client); 25 | } 26 | 27 | public int SaveWithSql(entities.Client client) 28 | { 29 | entities.Client hasClient = FindOne(client.GetId()); 30 | 31 | SQLiteCommand command; 32 | 33 | if (hasClient == null) 34 | { 35 | Add(client); 36 | command = new SQLiteCommand("INSERT INTO client(name, phone) VALUES(@name, @phone)", db.connection); 37 | } 38 | else 39 | { 40 | command = new SQLiteCommand("UPDATE client SET name = @name, phone = @phone WHERE id = @id ", db.connection); 41 | } 42 | 43 | command.Parameters.AddWithValue("@id", client.GetId()); 44 | command.Parameters.AddWithValue("@name", client.GetName()); 45 | command.Parameters.AddWithValue("@phone", client.GetPhone()); 46 | 47 | int num = command.ExecuteNonQuery(); 48 | 49 | return num; 50 | } 51 | 52 | public void Delete(entities.Client client) 53 | { 54 | clients.Remove(client); 55 | } 56 | 57 | public List GetList() 58 | { 59 | return clients; 60 | } 61 | 62 | public entities.Client FindOne(int id) 63 | { 64 | return clients.Find(x => x.GetId() == id); 65 | } 66 | 67 | public List FindByString(string str) 68 | { 69 | return clients.FindAll(x => x.GetNameAndPhone().Contains(str)); 70 | } 71 | 72 | public List FindByName(string name) 73 | { 74 | return clients.FindAll(x => x.GetName().Contains(name)); 75 | } 76 | 77 | public List FindByPhone(string name) 78 | { 79 | return clients.FindAll(x => x.GetPhone().Contains(name)); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /repositories/Discount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | 8 | namespace DvizhSeller.repositories 9 | { 10 | class Discount 11 | { 12 | private List discounts = new List(); 13 | 14 | services.Database db; 15 | 16 | public Discount(services.Database setDb) 17 | { 18 | db = setDb; 19 | } 20 | 21 | public void Add(entities.Discount discount) 22 | { 23 | discounts.Add(discount); 24 | } 25 | 26 | public int SaveWithSql(entities.Discount discount) 27 | { 28 | entities.Discount hasDiscount = FindOne(discount.GetId()); 29 | 30 | SQLiteCommand command; 31 | 32 | if(discount.GetId() == 0 | hasDiscount == null) 33 | { 34 | Add(discount); 35 | command = new SQLiteCommand("INSERT INTO discount(code, discount) VALUES(@code, @discount)", db.connection); 36 | } 37 | else 38 | { 39 | command = new SQLiteCommand("UPDATE discount SET code = @code, discount = @discount WHERE id = @id ", db.connection); 40 | } 41 | 42 | command.Parameters.AddWithValue("@id", discount.GetId()); 43 | command.Parameters.AddWithValue("@code", discount.GetCode()); 44 | command.Parameters.AddWithValue("@discount", discount.GetDiscount()); 45 | 46 | int num = command.ExecuteNonQuery(); 47 | 48 | return num; 49 | } 50 | 51 | public void Delete(entities.Discount discount) 52 | { 53 | discounts.Remove(discount); 54 | } 55 | 56 | public List GetList() 57 | { 58 | return discounts; 59 | } 60 | 61 | public entities.Discount FindOne(int id) 62 | { 63 | return discounts.Find(x => x.GetId() == id); 64 | } 65 | 66 | public entities.Discount FindOneByName(string name) 67 | { 68 | return discounts.Find(x => x.GetCode().ToLower().Trim() == name.ToLower().Trim()); 69 | } 70 | 71 | public List FindByCode(string name) 72 | { 73 | return discounts.FindAll(x => x.GetCode().Contains(name)); 74 | } 75 | 76 | public List FindByName(string name) 77 | { 78 | return discounts.FindAll(x => x.GetCode().Contains(name)); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /repositories/Cashier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | 8 | namespace DvizhSeller.repositories 9 | { 10 | class Cashier 11 | { 12 | private List cashiers = new List(); 13 | 14 | services.Database db; 15 | 16 | public Cashier(services.Database setDb) 17 | { 18 | db = setDb; 19 | } 20 | 21 | public void Add(entities.Cashier cashier) 22 | { 23 | cashiers.Add(cashier); 24 | } 25 | 26 | public int SaveWithSql(entities.Cashier cashier) 27 | { 28 | entities.Cashier hasCashier = FindOne(cashier.GetId()); 29 | 30 | SQLiteCommand command; 31 | 32 | if (cashier.GetId() == 0 | hasCashier == null) 33 | { 34 | Add(cashier); 35 | command = new SQLiteCommand("INSERT INTO cashier(name) VALUES(@name)", db.connection); 36 | } 37 | else 38 | { 39 | command = new SQLiteCommand("UPDATE cashier SET name = @name WHERE id = @id ", db.connection); 40 | } 41 | 42 | command.Parameters.AddWithValue("@id", cashier.GetId()); 43 | command.Parameters.AddWithValue("@name", cashier.GetName()); 44 | 45 | int num = command.ExecuteNonQuery(); 46 | 47 | return num; 48 | } 49 | 50 | public int DeleteWithSql(entities.Cashier cashier) 51 | { 52 | entities.Cashier hasCashier = FindOne(cashier.GetId()); 53 | 54 | SQLiteCommand command; 55 | 56 | command = new SQLiteCommand("DELETE FROM cashier WHERE id = @id", db.connection); 57 | 58 | command.Parameters.AddWithValue("@id", cashier.GetId()); 59 | 60 | int num = command.ExecuteNonQuery(); 61 | 62 | return num; 63 | } 64 | 65 | public void Delete(entities.Cashier cashbox) 66 | { 67 | cashiers.Remove(cashbox); 68 | } 69 | 70 | public List GetList() 71 | { 72 | return cashiers; 73 | } 74 | 75 | public entities.Cashier FindOne(int id) 76 | { 77 | return cashiers.Find(x => x.GetId() == id); 78 | } 79 | 80 | public List FindByName(string name) 81 | { 82 | return cashiers.FindAll(x => x.GetName().Contains(name)); 83 | } 84 | 85 | public void Clear() 86 | { 87 | cashiers.Clear(); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /ClientChooseForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace DvizhSeller 11 | { 12 | public partial class ClientChooseForm : Form 13 | { 14 | CashierForm cashierForm; 15 | 16 | services.Database db = new services.Database(); 17 | 18 | repositories.Client clients; 19 | services.DataMapper dataMapper; 20 | 21 | public ClientChooseForm(CashierForm setCashierForm) 22 | { 23 | cashierForm = setCashierForm; 24 | 25 | clients = new repositories.Client(db); 26 | 27 | dataMapper = new services.DataMapper(db); 28 | dataMapper.FillClients(clients); 29 | 30 | InitializeComponent(); 31 | } 32 | 33 | private void ClientsForm_Load(object sender, EventArgs e) 34 | { 35 | RenderClients(clients.GetList()); 36 | } 37 | 38 | 39 | private void RenderClients(List products) 40 | { 41 | clientsListView.Items.Clear(); 42 | 43 | foreach (entities.Client client in products) 44 | { 45 | Item item = new Item(client.GetName(), client.GetId()); 46 | 47 | dynamic row = clientsListView.Items.Add(client.GetName()); 48 | 49 | row.Tag = item.Value; 50 | 51 | int index = row.Index; 52 | 53 | clientsListView.Items[index].SubItems.Add(client.GetPhone().ToString()); 54 | } 55 | } 56 | 57 | private class Item 58 | { 59 | public string Name; 60 | public int Value; 61 | 62 | public Item(string name, int value) 63 | { 64 | Name = name; Value = value; 65 | } 66 | 67 | public override string ToString() 68 | { 69 | return Name; 70 | } 71 | } 72 | 73 | private void textBox1_KeyDown(object sender, KeyEventArgs e) 74 | { 75 | if (searchBox.Text == "") 76 | RenderClients(clients.GetList()); 77 | else 78 | RenderClients(clients.FindByString(searchBox.Text)); 79 | } 80 | 81 | private void clientsListView_DoubleClick(object sender, EventArgs e) 82 | { 83 | foreach (ListViewItem item in clientsListView.SelectedItems) 84 | { 85 | entities.Client client = clients.FindOne(Convert.ToInt32(item.Tag)); 86 | cashierForm.ChooseClient(client.GetId(), client.GetName()); 87 | } 88 | 89 | this.Close(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /BarcodeScanerForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class BarcodeScanerForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BarcodeScanerForm)); 32 | this.barCodeBox = new System.Windows.Forms.TextBox(); 33 | this.SuspendLayout(); 34 | // 35 | // barCodeBox 36 | // 37 | this.barCodeBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 38 | this.barCodeBox.Location = new System.Drawing.Point(12, 12); 39 | this.barCodeBox.Name = "barCodeBox"; 40 | this.barCodeBox.Size = new System.Drawing.Size(260, 40); 41 | this.barCodeBox.TabIndex = 10; 42 | this.barCodeBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.barCodeBox_KeyDown); 43 | // 44 | // BarcodeScanerForm 45 | // 46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 48 | this.ClientSize = new System.Drawing.Size(284, 67); 49 | this.Controls.Add(this.barCodeBox); 50 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 51 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 52 | this.MaximizeBox = false; 53 | this.MinimizeBox = false; 54 | this.Name = "BarcodeScanerForm"; 55 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 56 | this.Text = "Купить по штрихкоду"; 57 | this.Load += new System.EventHandler(this.BarcodeScanerForm_Load); 58 | this.ResumeLayout(false); 59 | this.PerformLayout(); 60 | 61 | } 62 | 63 | #endregion 64 | 65 | private System.Windows.Forms.TextBox barCodeBox; 66 | } 67 | } -------------------------------------------------------------------------------- /entities/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | class Order 10 | { 11 | int id; 12 | int dvizh_id; 13 | string date; 14 | double total; 15 | string cancel_at; 16 | int cashier_id; 17 | int client_id; 18 | int discount_id; 19 | 20 | private List elements = new List(); 21 | 22 | public Order(int setId, string setDate, double setTotal, int setCashier, int setClient, int setDiscount, int setDvizhId = 0) 23 | { 24 | id = setId; 25 | date = setDate; 26 | total = setTotal; 27 | cashier_id = setCashier; 28 | client_id = setClient; 29 | discount_id = setDiscount; 30 | dvizh_id = setDvizhId; 31 | } 32 | 33 | public void AddElement(entities.OrderElement element) 34 | { 35 | elements.Add(element); 36 | } 37 | 38 | public List GetElements() 39 | { 40 | return elements; 41 | } 42 | 43 | public int Id 44 | { 45 | get { return id; } 46 | set { id = value; } 47 | } 48 | 49 | public int DvizhId 50 | { 51 | get { return dvizh_id; } 52 | set { dvizh_id = value; } 53 | } 54 | 55 | public int cashierId 56 | { 57 | get { return cashier_id; } 58 | set { cashier_id = value; } 59 | } 60 | 61 | public int clientId 62 | { 63 | get { return client_id; } 64 | set { client_id = value; } 65 | } 66 | 67 | public int discountId 68 | { 69 | get { return discount_id; } 70 | set { discount_id = value; } 71 | } 72 | 73 | public double Total 74 | { 75 | get { return total; } 76 | set { total = value; } 77 | } 78 | 79 | public string Date 80 | { 81 | get { return date; } 82 | set { date = value; } 83 | } 84 | 85 | public int GetId() 86 | { 87 | return id; 88 | } 89 | 90 | public double GetTotal() 91 | { 92 | return total; 93 | } 94 | 95 | public int GetDiscountId() 96 | { 97 | return discount_id; 98 | } 99 | 100 | public string GetDate() 101 | { 102 | return date; 103 | } 104 | 105 | public int GetCashierId() 106 | { 107 | return cashier_id; 108 | } 109 | 110 | public int GetClientId() 111 | { 112 | return client_id; 113 | } 114 | 115 | public void SetDvizhId(int setDvizhId) 116 | { 117 | dvizh_id = setDvizhId; 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | database.db 7 | 8 | 9 | 15 10 | 11 | 12 | р. 13 | 14 | 15 | dvizh.net 16 | 17 | 18 | http 19 | 20 | 21 | demo4 22 | 23 | 24 | k2j33hdj39aqskdenneckksa303kd 25 | 26 | 27 | False 28 | 29 | 30 | True 31 | 32 | 33 | dvizh.net 34 | 35 | 36 | True 37 | 38 | 39 | 1 40 | 41 | 42 | 1 43 | 44 | 45 | 0 46 | 47 | 48 | backend/web/csvapi 49 | 50 | 51 | ? 52 | 53 | 54 | False 55 | 56 | 57 | 1 58 | 59 | 60 | COM5 61 | 62 | 63 | False 64 | 65 | 66 | 1 67 | 68 | 69 | True 70 | 71 | 72 | -------------------------------------------------------------------------------- /services/WebServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Net; 7 | using System.Threading; 8 | using System.Web.Http; 9 | 10 | 11 | namespace DvizhSeller 12 | { 13 | public class WebServer 14 | { 15 | private readonly HttpListener _listener = new HttpListener(); 16 | private readonly Func _responderMethod; 17 | 18 | public WebServer(string[] prefixes, Func method) 19 | { 20 | if (!HttpListener.IsSupported) 21 | throw new NotSupportedException( 22 | "Needs Windows XP SP2, Server 2003 or later."); 23 | 24 | if (prefixes == null || prefixes.Length == 0) 25 | throw new ArgumentException("prefixes"); 26 | 27 | if (method == null) 28 | throw new ArgumentException("method"); 29 | 30 | foreach (string s in prefixes) 31 | _listener.Prefixes.Add(s); 32 | 33 | _responderMethod = method; 34 | _listener.Start(); 35 | } 36 | 37 | ~WebServer() 38 | { 39 | _listener.Stop(); 40 | _listener.Close(); 41 | } 42 | 43 | public WebServer(Func method, params string[] prefixes) 44 | : this(prefixes, method) { } 45 | 46 | public void Run() 47 | { 48 | ThreadPool.QueueUserWorkItem((o) => 49 | { 50 | Console.WriteLine("Webserver running..."); 51 | try 52 | { 53 | while (_listener.IsListening) 54 | { 55 | ThreadPool.QueueUserWorkItem((c) => 56 | { 57 | var ctx = c as HttpListenerContext; 58 | try 59 | { 60 | string rstr = _responderMethod(ctx.Request); 61 | byte[] buf = Encoding.UTF8.GetBytes(rstr); 62 | ctx.Response.ContentLength64 = buf.Length; 63 | ctx.Response.OutputStream.Write(buf, 0, buf.Length); 64 | ctx.Response.AddHeader("Access-Control-Allow-Origin","*"); 65 | } 66 | catch { } 67 | finally 68 | { 69 | ctx.Response.OutputStream.Close(); 70 | } 71 | }, _listener.GetContext()); 72 | } 73 | } 74 | catch { } 75 | }); 76 | } 77 | 78 | public static class WebApiConfig 79 | { 80 | public static void Register(HttpConfiguration config) 81 | { 82 | config.EnableCors(); 83 | 84 | config.MapHttpAttributeRoutes(); 85 | config.Routes.MapHttpRoute( 86 | name: "DefaultApi", 87 | routeTemplate: "api/{controller}/{id}", 88 | defaults: new { id = RouteParameter.Optional } 89 | ); 90 | // ... 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Этот код создан программой. 4 | // Исполняемая версия:4.0.30319.42000 5 | // 6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае 7 | // повторной генерации кода. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DvizhSeller.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. 17 | /// 18 | // Этот класс создан автоматически классом StronglyTypedResourceBuilder 19 | // с помощью такого средства, как ResGen или Visual Studio. 20 | // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen 21 | // с параметром /str или перестройте свой проект VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DvizhSeller.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Перезаписывает свойство CurrentUICulture текущего потока для всех 51 | /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Поиск локализованного ресурса типа System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap placeholder { 67 | get { 68 | object obj = ResourceManager.GetObject("placeholder", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /OrdersForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class OrdersForm : Form 14 | { 15 | services.Database db = new services.Database(); 16 | 17 | tools.OrderProvider ordersProvider = new tools.OrderProvider(); 18 | tools.OrderElementProvider elementsProvider; 19 | 20 | repositories.Order orders; 21 | services.DataMapper dataMapper; 22 | 23 | string cashierName; 24 | 25 | public services.Fiscal fiscal; 26 | 27 | public OrdersForm(services.Fiscal setFiscal, string setCashierName = "Unknow") 28 | { 29 | fiscal = setFiscal; 30 | cashierName = setCashierName; 31 | 32 | InitializeComponent(); 33 | 34 | orders = new repositories.Order(db); 35 | 36 | dataMapper = new services.DataMapper(db); 37 | dataMapper.FillOrders(orders); 38 | 39 | foreach (entities.Order order in orders.GetList()) 40 | { 41 | ordersProvider.Add(order); 42 | } 43 | 44 | ordersListGridView.DataSource = ordersProvider; 45 | 46 | if (orders.GetList().Count() > 0) 47 | { 48 | orderElementsBox.Visible = true; 49 | 50 | entities.Order order = orders.GetList()[0]; 51 | 52 | elementsProvider = new tools.OrderElementProvider(); 53 | 54 | foreach (entities.OrderElement orderElement in order.GetElements()) 55 | { 56 | elementsProvider.Add(orderElement); 57 | } 58 | 59 | elementsListGridView.DataSource = elementsProvider; 60 | } 61 | } 62 | 63 | private void OrdersForm_Load(object sender, EventArgs e) 64 | { 65 | 66 | } 67 | 68 | private void ordersListGridView_CellClick(object sender, DataGridViewCellEventArgs e) 69 | { 70 | orderElementsBox.Visible = true; 71 | 72 | int index = ordersListGridView.CurrentCell.RowIndex; 73 | 74 | entities.Order order = orders.GetList()[index]; 75 | 76 | elementsProvider = new tools.OrderElementProvider(); 77 | 78 | foreach(entities.OrderElement orderElement in order.GetElements()) 79 | { 80 | elementsProvider.Add(orderElement); 81 | } 82 | 83 | elementsListGridView.DataSource = elementsProvider; 84 | } 85 | 86 | private void canceSelectedElement_Click(object sender, EventArgs e) 87 | { 88 | int index = elementsListGridView.CurrentCell.RowIndex; 89 | entities.OrderElement orderElement = elementsProvider[index]; 90 | 91 | orderElement.SetCancelAt(DateTime.Now.ToLongDateString()); 92 | orders.CancelElement(orderElement); 93 | 94 | if(Properties.Settings.Default.fiscal) 95 | { 96 | fiscal.SetCashier(cashierName); 97 | fiscal.Annulate(orderElement); 98 | } 99 | 100 | elementsListGridView.Update(); 101 | elementsListGridView.Focus(); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /repositories/Cart.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.repositories 8 | { 9 | public class Cart 10 | { 11 | private List products = new List(); 12 | 13 | entities.Discount discount = null; 14 | services.Rounder rounder = new services.Rounder(); 15 | 16 | public void Put(entities.interfaces.CartElement product, int count = 1) 17 | { 18 | if(product.GetId() != 0) 19 | { 20 | foreach (entities.interfaces.CartElement existsProduct in GetElements()) 21 | { 22 | if (existsProduct.GetId() == product.GetId()) 23 | { 24 | existsProduct.SetCartCount(existsProduct.GetCartCount() + count); 25 | 26 | return; 27 | } 28 | } 29 | } 30 | product.SetCartCount(count); 31 | products.Add(product); 32 | } 33 | 34 | public void Clear() 35 | { 36 | products = new List(); 37 | } 38 | 39 | public void Delete(entities.interfaces.CartElement product) 40 | { 41 | products.Remove(product); 42 | } 43 | 44 | public List GetElements() 45 | { 46 | return products; 47 | } 48 | 49 | public entities.interfaces.CartElement FindOne(int id) 50 | { 51 | return products.Find(x => x.GetId() == id); 52 | } 53 | 54 | public List FindByString(string str) 55 | { 56 | return products.FindAll(x => x.GetNameAndSku().ToLower().Contains(str.ToLower())); 57 | } 58 | 59 | public List FindByCategory(entities.Category category) 60 | { 61 | return products.FindAll(x => x.GetCategoryId() == category.GetId()); 62 | } 63 | 64 | public List FindByCategoryId(int categoryId) 65 | { 66 | return products.FindAll(x => x.GetCategoryId() == categoryId); 67 | } 68 | 69 | public int GetCount() 70 | { 71 | int count = 0; 72 | 73 | foreach(entities.interfaces.CartElement product in GetElements()) { 74 | count += product.GetCartCount(); 75 | } 76 | 77 | return count; 78 | } 79 | 80 | public double GetTotal() 81 | { 82 | double total = 0; 83 | 84 | foreach (entities.interfaces.CartElement product in GetElements()) 85 | { 86 | total += product.GetPrice() * product.GetCartCount(); 87 | } 88 | 89 | double returnTotal = 0; 90 | 91 | if (discount != null && total > 0) 92 | { 93 | returnTotal = total - (total * discount.GetDiscount() / 100); 94 | } 95 | else 96 | returnTotal = total; 97 | 98 | return rounder.Round(returnTotal); 99 | } 100 | 101 | public void SetDiscount(entities.Discount setDiscount) 102 | { 103 | discount = setDiscount; 104 | } 105 | 106 | public int GetDiscount() 107 | { 108 | if(discount != null)return discount.GetDiscount(); 109 | return 0; 110 | } 111 | 112 | public void UnsetDiscount() 113 | { 114 | discount = null; 115 | } 116 | 117 | public byte GetDiscType() 118 | { 119 | return discount.GetType(); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /DataExchangeForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class DataExchangeForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataExchangeForm)); 32 | this.totalProgressBar = new System.Windows.Forms.ProgressBar(); 33 | this.messageBox = new System.Windows.Forms.Label(); 34 | this.messageBox2 = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // totalProgressBar 38 | // 39 | this.totalProgressBar.Location = new System.Drawing.Point(12, 27); 40 | this.totalProgressBar.Maximum = 7; 41 | this.totalProgressBar.Name = "totalProgressBar"; 42 | this.totalProgressBar.Size = new System.Drawing.Size(438, 23); 43 | this.totalProgressBar.TabIndex = 0; 44 | // 45 | // messageBox 46 | // 47 | this.messageBox.AutoSize = true; 48 | this.messageBox.Location = new System.Drawing.Point(13, 57); 49 | this.messageBox.Name = "messageBox"; 50 | this.messageBox.Size = new System.Drawing.Size(61, 13); 51 | this.messageBox.TabIndex = 1; 52 | this.messageBox.Text = "Состояние"; 53 | this.messageBox.Visible = false; 54 | // 55 | // messageBox2 56 | // 57 | this.messageBox2.AutoSize = true; 58 | this.messageBox2.Location = new System.Drawing.Point(13, 73); 59 | this.messageBox2.Name = "messageBox2"; 60 | this.messageBox2.Size = new System.Drawing.Size(34, 13); 61 | this.messageBox2.TabIndex = 2; 62 | this.messageBox2.Text = " "; 63 | this.messageBox2.Visible = false; 64 | // 65 | // DataExchangeForm 66 | // 67 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 68 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 69 | this.ClientSize = new System.Drawing.Size(462, 95); 70 | this.Controls.Add(this.messageBox2); 71 | this.Controls.Add(this.messageBox); 72 | this.Controls.Add(this.totalProgressBar); 73 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 74 | this.MaximizeBox = false; 75 | this.MinimizeBox = false; 76 | this.Name = "DataExchangeForm"; 77 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 78 | this.Text = "Обмен данными"; 79 | this.TopMost = true; 80 | this.Load += new System.EventHandler(this.DataExchangeForm_Load); 81 | this.ResumeLayout(false); 82 | this.PerformLayout(); 83 | 84 | } 85 | 86 | #endregion 87 | 88 | private System.Windows.Forms.ProgressBar totalProgressBar; 89 | private System.Windows.Forms.Label messageBox; 90 | private System.Windows.Forms.Label messageBox2; 91 | } 92 | } -------------------------------------------------------------------------------- /repositories/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using System.Data.SQLite; 8 | 9 | namespace DvizhSeller.repositories 10 | { 11 | class Order 12 | { 13 | private List orders = new List(); 14 | 15 | services.Database db; 16 | 17 | public Order(services.Database setDb) 18 | { 19 | db = setDb; 20 | } 21 | 22 | public void Add(entities.Order order) 23 | { 24 | orders.Add(order); 25 | } 26 | 27 | public void SaveDvizhIdWithSql(entities.Order order, int dvizhId) 28 | { 29 | SQLiteCommand orderCommand = new SQLiteCommand("UPDATE order_list SET dvizh_id = @dvizh_id WHERE id = @id", db.connection); 30 | 31 | orderCommand.Parameters.AddWithValue("@dvizh_id", dvizhId); 32 | orderCommand.Parameters.AddWithValue("@id", order.GetId()); 33 | 34 | orderCommand.ExecuteNonQuery(); 35 | } 36 | 37 | public void CancelElement(entities.OrderElement element) 38 | { 39 | SQLiteCommand orderCommand = new SQLiteCommand("UPDATE order_element_list SET cancel_at = @cancel_at WHERE id = @id", db.connection); 40 | 41 | orderCommand.Parameters.AddWithValue("@cancel_at", DateTime.Now.ToLongDateString()); 42 | orderCommand.Parameters.AddWithValue("@id", element.GetId()); 43 | 44 | orderCommand.ExecuteNonQuery(); 45 | } 46 | 47 | public void AddWithSql(entities.Order order) 48 | { 49 | Add(order); 50 | 51 | SQLiteCommand orderCommand; 52 | 53 | orderCommand = new SQLiteCommand("INSERT INTO order_list(dvizh_id, date, total, cashier_id, client_id, discount_id) VALUES(@dvizh_id, @date, @total, @cashier_id, @client_id, @discount_id)", db.connection); 54 | 55 | orderCommand.Parameters.AddWithValue("@dvizh_id", order.DvizhId); 56 | orderCommand.Parameters.AddWithValue("@date", order.Date); 57 | orderCommand.Parameters.AddWithValue("@cashier_id", order.cashierId); 58 | orderCommand.Parameters.AddWithValue("@client_id", order.clientId); 59 | orderCommand.Parameters.AddWithValue("@discount_id", order.discountId); 60 | orderCommand.Parameters.AddWithValue("@total", order.Total.ToString()); 61 | 62 | orderCommand.ExecuteNonQuery(); 63 | 64 | orderCommand.CommandText = "SELECT last_insert_rowid()"; 65 | 66 | Int64 LastRowID64 = (Int64)orderCommand.ExecuteScalar(); 67 | 68 | order.Id = (int)LastRowID64; 69 | 70 | foreach (entities.OrderElement element in order.GetElements()) 71 | { 72 | SQLiteCommand elementCommand = new SQLiteCommand("INSERT INTO order_element_list(order_id, product_id, product_name, count, price) values(@order_id, @product_id, @product_name, @count, @price)", db.connection); 73 | 74 | elementCommand.Parameters.AddWithValue("@order_id", order.GetId()); 75 | elementCommand.Parameters.AddWithValue("@product_id", element.GetProductId()); 76 | elementCommand.Parameters.AddWithValue("@product_name", element.GetProductName()); 77 | elementCommand.Parameters.AddWithValue("@count", element.GetCount()); 78 | elementCommand.Parameters.AddWithValue("@price", element.GetPrice().ToString()); 79 | 80 | elementCommand.ExecuteNonQuery(); 81 | } 82 | } 83 | 84 | public void Delete(entities.Order order) 85 | { 86 | orders.Remove(order); 87 | } 88 | 89 | public List GetList() 90 | { 91 | return orders; 92 | } 93 | 94 | public entities.Order FindOne(int id) 95 | { 96 | return orders.Find(x => x.GetId() == id); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /TabletForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class TabletForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TabletForm)); 32 | this.textBox1 = new System.Windows.Forms.TextBox(); 33 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 34 | this.SuspendLayout(); 35 | // 36 | // textBox1 37 | // 38 | this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; 39 | this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 40 | this.textBox1.Location = new System.Drawing.Point(0, 0); 41 | this.textBox1.Name = "textBox1"; 42 | this.textBox1.Size = new System.Drawing.Size(929, 47); 43 | this.textBox1.TabIndex = 0; 44 | // 45 | // tableLayoutPanel1 46 | // 47 | this.tableLayoutPanel1.ColumnCount = 2; 48 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 49 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 50 | this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 53); 51 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 52 | this.tableLayoutPanel1.RowCount = 2; 53 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 54 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 55 | this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 100); 56 | this.tableLayoutPanel1.TabIndex = 1; 57 | // 58 | // TabletForm 59 | // 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 61 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 62 | this.AutoScroll = true; 63 | this.ClientSize = new System.Drawing.Size(929, 495); 64 | this.Controls.Add(this.tableLayoutPanel1); 65 | this.Controls.Add(this.textBox1); 66 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 67 | this.Name = "TabletForm"; 68 | this.RightToLeft = System.Windows.Forms.RightToLeft.No; 69 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 70 | this.Text = "Реализация товара"; 71 | this.TopMost = true; 72 | this.WindowState = System.Windows.Forms.FormWindowState.Maximized; 73 | this.Load += new System.EventHandler(this.TabletForm_Load); 74 | this.ResumeLayout(false); 75 | this.PerformLayout(); 76 | 77 | } 78 | 79 | #endregion 80 | 81 | private System.Windows.Forms.TextBox textBox1; 82 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 83 | } 84 | } -------------------------------------------------------------------------------- /repositories/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | using System.Windows.Forms; 8 | 9 | namespace DvizhSeller.repositories 10 | { 11 | class Product 12 | { 13 | private List products = new List(); 14 | 15 | services.Database db; 16 | 17 | public Product(services.Database setDb) 18 | { 19 | db = setDb; 20 | } 21 | 22 | public void Add(entities.Product product) 23 | { 24 | products.Add(product); 25 | } 26 | 27 | public int SaveWithSql(entities.Product product) 28 | { 29 | entities.Product hasProduct = FindOne(product.GetId()); 30 | 31 | SQLiteCommand command; 32 | 33 | if (product.GetId() == 0 | hasProduct == null) 34 | { 35 | Add(product); 36 | 37 | command = new SQLiteCommand("INSERT INTO product(sku, name, price, category_id, image, amount) VALUES(@sku, @name, @price, @category_id, @image, @amount)", db.connection); 38 | } 39 | else 40 | { 41 | command = new SQLiteCommand("UPDATE product SET sku = @sku, name = @name, price = @price, category_id = @category_id, image = @image, amount = @amount WHERE id = @id ", db.connection); 42 | } 43 | 44 | command.Parameters.AddWithValue("@id", product.GetId()); 45 | command.Parameters.AddWithValue("@sku", product.GetSku()); 46 | command.Parameters.AddWithValue("@name", product.GetName()); 47 | command.Parameters.AddWithValue("@price", Convert.ToDecimal(product.GetPrice())); 48 | command.Parameters.AddWithValue("@category_id", product.GetCategoryId()); 49 | command.Parameters.AddWithValue("@image", product.GetImage()); 50 | command.Parameters.AddWithValue("@amount", product.GetAmount()); 51 | 52 | int num = command.ExecuteNonQuery(); 53 | 54 | return num; 55 | } 56 | 57 | public int DeleteWithSql(entities.Product product) 58 | { 59 | entities.Product hasProduct = FindOne(product.GetId()); 60 | 61 | SQLiteCommand command; 62 | 63 | command = new SQLiteCommand("DELETE FROM product WHERE id = @id", db.connection); 64 | 65 | command.Parameters.AddWithValue("@id", product.GetId()); 66 | 67 | int num = command.ExecuteNonQuery(); 68 | 69 | return num; 70 | } 71 | 72 | public void Delete(entities.Product product) 73 | { 74 | products.Remove(product); 75 | } 76 | 77 | public void Clear() 78 | { 79 | products.Clear(); 80 | } 81 | 82 | public List GetList() 83 | { 84 | return products; 85 | } 86 | 87 | public entities.Product FindOne(int id) 88 | { 89 | return products.Find(x => x.GetId() == id); 90 | } 91 | 92 | public List FindByString(string str) 93 | { 94 | return products.FindAll(x => x.GetNameAndSku().ToLower().Contains(str.ToLower())); 95 | } 96 | 97 | public List FindByCategory(entities.Category category) 98 | { 99 | return products.FindAll(x => x.GetCategoryId() == category.GetId()); 100 | } 101 | 102 | public List FindByCategoryId(int categoryId) 103 | { 104 | return products.FindAll(x => x.GetCategoryId() == categoryId); 105 | } 106 | 107 | public List FindBySku(string sku) 108 | { 109 | return products.FindAll(x => x.GetSku() == sku); 110 | } 111 | 112 | public entities.Product FindOneBySku(string sku) 113 | { 114 | return products.Find(x => x.GetSku() == sku); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /CashiersBookForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class CashiersBookForm : Form 14 | { 15 | CashierForm cashierForm; 16 | 17 | services.Database db = new services.Database(); 18 | 19 | tools.CashierProvider cashiersProvider = new tools.CashierProvider(); 20 | 21 | repositories.Cashier cashiers; 22 | 23 | services.DataMapper dataMapper; 24 | 25 | entities.Cashier selectedCashier = null; 26 | 27 | public CashiersBookForm(CashierForm setCashierForm) 28 | { 29 | InitializeComponent(); 30 | 31 | cashierForm = setCashierForm; 32 | 33 | if (cashiersProvider.Count > 0) 34 | { 35 | SelectFormCashier(cashiersProvider[0]); 36 | } 37 | } 38 | 39 | private void SelectFormCashier(entities.Cashier cashier) 40 | { 41 | selectedCashier = cashier; 42 | cashierBox.Visible = true; 43 | cashierNameBox.Text = cashier.GetName(); 44 | } 45 | 46 | private bool AddCashier() 47 | { 48 | if (addCashierNameBox.Text == "") 49 | { 50 | MessageBox.Show("Имя обязательно"); 51 | 52 | return false; 53 | } 54 | 55 | entities.Cashier cashier = new entities.Cashier(0, addCashierNameBox.Text); 56 | 57 | cashiers.SaveWithSql(cashier); 58 | 59 | cashiersProvider.Add(cashier); 60 | 61 | cashiersGridView.Update(); 62 | 63 | addCashierNameBox.Text = ""; 64 | 65 | MessageBox.Show("Сохранено"); 66 | 67 | return true; 68 | } 69 | 70 | 71 | private void CashiersBookForm_Load(object sender, EventArgs e) 72 | { 73 | cashiers = new repositories.Cashier(db); 74 | 75 | dataMapper = new services.DataMapper(db); 76 | dataMapper.FillCashiers(cashiers); 77 | 78 | foreach (entities.Cashier cashier in cashiers.GetList()) 79 | { 80 | cashiersProvider.Add(cashier); 81 | } 82 | 83 | 84 | if (cashiersProvider.Count > 0) 85 | { 86 | SelectFormCashier(cashiersProvider[0]); 87 | } 88 | 89 | cashiersGridView.DataSource = cashiersProvider; 90 | 91 | cashiersGridView.Update(); 92 | } 93 | 94 | private void saveButton_Click(object sender, EventArgs e) 95 | { 96 | if (selectedCashier != null) 97 | { 98 | selectedCashier.SetName(cashierNameBox.Text); 99 | 100 | cashiers.SaveWithSql(selectedCashier); 101 | 102 | MessageBox.Show("Сохранено"); 103 | } 104 | 105 | cashiersGridView.Update(); 106 | cashiersGridView.Focus(); 107 | } 108 | 109 | private void deleteButton_Click(object sender, EventArgs e) 110 | { 111 | if (selectedCashier != null) 112 | { 113 | cashiers.DeleteWithSql(selectedCashier); 114 | 115 | cashiersProvider.Remove(selectedCashier); 116 | 117 | cashierBox.Visible = false; 118 | } 119 | 120 | cashiersGridView.Update(); 121 | cashiersGridView.Focus(); 122 | } 123 | 124 | private void addCashierButton_Click(object sender, EventArgs e) 125 | { 126 | AddCashier(); 127 | } 128 | 129 | private void cashiersGridView_CellClick(object sender, DataGridViewCellEventArgs e) 130 | { 131 | SelectFormCashier(cashiersProvider[cashiersGridView.CurrentCell.RowIndex]); 132 | } 133 | 134 | private void CashiersBookForm_FormClosed(object sender, FormClosedEventArgs e) 135 | { 136 | cashierForm.ReRenderAllCashiers(); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /entities/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DvizhSeller.entities 8 | { 9 | public class Product : interfaces.CartElement 10 | { 11 | int id; 12 | string name; 13 | string sku; 14 | string image; 15 | int amount; 16 | double price; 17 | Category category = null; 18 | int categoryId = 0; 19 | int cartcount = 1; 20 | 21 | public Product(int setId, string setSku, string setName, double setPrice, Category setCategory = null, string setImage = null, int setAmount = 0) 22 | { 23 | id = setId; 24 | sku = setSku; 25 | name = setName; 26 | price = setPrice; 27 | image = setImage; 28 | amount = setAmount; 29 | 30 | if (setCategory != null) 31 | { 32 | category = setCategory; 33 | categoryId = category.GetId(); 34 | } 35 | } 36 | 37 | public string Name 38 | { 39 | get { return name; } 40 | set { name = value; } 41 | } 42 | 43 | public string Sku 44 | { 45 | get { return sku; } 46 | set { sku = value; } 47 | } 48 | 49 | public double Price 50 | { 51 | get { return price; } 52 | set { price = value; } 53 | } 54 | 55 | public int Amount 56 | { 57 | get { return amount; } 58 | set { amount = value; } 59 | } 60 | 61 | public int CategoryId 62 | { 63 | get { return categoryId; } 64 | set { categoryId = value; } 65 | } 66 | 67 | public Category Category 68 | { 69 | get { return category; } 70 | set { category = value; } 71 | } 72 | 73 | public int CartCount 74 | { 75 | get { return cartcount; } 76 | set { cartcount = value; } 77 | } 78 | 79 | public string GetName() 80 | { 81 | return name; 82 | } 83 | 84 | public int GetId() 85 | { 86 | return id; 87 | } 88 | 89 | public Category GetCategory() 90 | { 91 | return category; 92 | } 93 | 94 | public int GetCategoryId() 95 | { 96 | return categoryId; 97 | } 98 | 99 | public double GetPrice() 100 | { 101 | return price; 102 | } 103 | 104 | public string GetSku() 105 | { 106 | return sku; 107 | } 108 | 109 | public int GetAmount() 110 | { 111 | return amount; 112 | } 113 | 114 | public string GetImage() 115 | { 116 | return image; 117 | } 118 | 119 | public string GetNameAndSku() 120 | { 121 | return sku + " " + name; 122 | } 123 | 124 | public int GetCartCount() 125 | { 126 | return cartcount; 127 | } 128 | 129 | public void SetCartCount(int count) 130 | { 131 | cartcount = count; 132 | } 133 | 134 | public void SetName(string setName) 135 | { 136 | name = setName; 137 | } 138 | 139 | public void SetCategoryId(int setCategoryId) 140 | { 141 | categoryId = setCategoryId; 142 | } 143 | 144 | public void SetPrice(double setPrice) 145 | { 146 | price = setPrice; 147 | } 148 | 149 | public void SetSku(string setSku) 150 | { 151 | sku = setSku; 152 | } 153 | 154 | public void SetAmount(int setAmount) 155 | { 156 | amount = setAmount; 157 | } 158 | 159 | public void SetImage(string setImage) 160 | { 161 | image = setImage; 162 | } 163 | } 164 | 165 | public class UpdateEventArgs : EventArgs 166 | { 167 | //public Product product { get; set; } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /CashierChooseForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class CashierChooseForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CashierChooseForm)); 32 | this.cashiersList = new System.Windows.Forms.ComboBox(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.chooseButton = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // cashiersList 38 | // 39 | this.cashiersList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 40 | this.cashiersList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 41 | this.cashiersList.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 42 | this.cashiersList.Location = new System.Drawing.Point(12, 36); 43 | this.cashiersList.Name = "cashiersList"; 44 | this.cashiersList.Size = new System.Drawing.Size(260, 32); 45 | this.cashiersList.TabIndex = 0; 46 | // 47 | // label1 48 | // 49 | this.label1.AutoSize = true; 50 | this.label1.Location = new System.Drawing.Point(13, 13); 51 | this.label1.Name = "label1"; 52 | this.label1.Size = new System.Drawing.Size(102, 13); 53 | this.label1.TabIndex = 1; 54 | this.label1.Text = "Выберите кассира"; 55 | // 56 | // chooseButton 57 | // 58 | this.chooseButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 59 | this.chooseButton.Location = new System.Drawing.Point(98, 78); 60 | this.chooseButton.Name = "chooseButton"; 61 | this.chooseButton.Size = new System.Drawing.Size(80, 33); 62 | this.chooseButton.TabIndex = 2; 63 | this.chooseButton.Text = "Войти"; 64 | this.chooseButton.UseVisualStyleBackColor = true; 65 | this.chooseButton.Click += new System.EventHandler(this.chooseButton_Click); 66 | // 67 | // CashierChooseForm 68 | // 69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 71 | this.ClientSize = new System.Drawing.Size(284, 123); 72 | this.Controls.Add(this.chooseButton); 73 | this.Controls.Add(this.label1); 74 | this.Controls.Add(this.cashiersList); 75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 76 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 77 | this.MaximizeBox = false; 78 | this.MinimizeBox = false; 79 | this.Name = "CashierChooseForm"; 80 | this.ShowInTaskbar = false; 81 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 82 | this.Text = "Выбор кассира"; 83 | this.TopMost = true; 84 | this.Load += new System.EventHandler(this.CashierChooseForm_Load); 85 | this.ResumeLayout(false); 86 | this.PerformLayout(); 87 | 88 | } 89 | 90 | #endregion 91 | 92 | private System.Windows.Forms.ComboBox cashiersList; 93 | private System.Windows.Forms.Label label1; 94 | private System.Windows.Forms.Button chooseButton; 95 | } 96 | } -------------------------------------------------------------------------------- /services/Fiscal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace DvizhSeller.services 6 | { 7 | public class Fiscal 8 | { 9 | repositories.Cart cart; 10 | drivers.FiscalInterface driver; 11 | byte tax_id; 12 | 13 | public const int DOC_TYPE_SERVICE = 1; //For print texts 14 | public const int DOC_TYPE_REGISTER = 2; //For fiscal registration 15 | public const int DOC_TYPE_RETURN = 3; 16 | public const int DOC_TYPE_INCOME = 4; 17 | public const int DOC_TYPE_OUTCOME = 5; 18 | public const int DOC_TYPE_BUY = 6; 19 | public const int DOC_TYPE_ANNULATE = 7; 20 | 21 | public Fiscal(drivers.FiscalAbstractFabricInterface fiscalFabric, repositories.Cart setCart = null) 22 | { 23 | driver = fiscalFabric.Build(); 24 | cart = setCart; 25 | tax_id = 0; 26 | } 27 | 28 | public bool Ready() 29 | { 30 | return driver.Ready(); 31 | } 32 | 33 | public void PrintString(string str) 34 | { 35 | driver.OpenDocument(DOC_TYPE_SERVICE); 36 | driver.PrintString(str); 37 | driver.CloseDocument(); 38 | } 39 | 40 | public void TestPrint() 41 | { 42 | driver.PrintServiceData(); 43 | } 44 | 45 | public void March() 46 | { 47 | //)))) 48 | } 49 | 50 | public void Storning(entities.OrderElement orderElement) 51 | { 52 | driver.OpenDocument(DOC_TYPE_OUTCOME); 53 | driver.Storning(orderElement.GetProductName(), orderElement.GetCount(), orderElement.GetPrice()); 54 | driver.PrintTotal(); 55 | driver.CloseDocument(); 56 | } 57 | 58 | public void Annulate(entities.OrderElement orderElement) 59 | { 60 | driver.OpenDocument(DOC_TYPE_ANNULATE); 61 | driver.AnnulateProduct(orderElement.GetProductName(), orderElement.GetCount(), orderElement.GetPrice()); 62 | driver.PrintTotal(); 63 | driver.RegisterPayment(orderElement.GetPrice(), 0); 64 | driver.CloseDocument(); 65 | } 66 | 67 | public void SetCashier(string cashierName) 68 | { 69 | driver.SetCashierName(cashierName); 70 | } 71 | 72 | public void Register(byte paymentType = 0) 73 | { 74 | if (cart.GetCount() <= 0) 75 | driver.OpenDocument(DOC_TYPE_BUY); 76 | int i = 1; 77 | double cartSum = cart.GetTotal(); 78 | double sum = 0; 79 | if (cart.GetDiscount() >= 1) driver.RegisterDiscount(cart.GetDiscType(), "-", cart.GetDiscount()); ; 80 | foreach (entities.Product element in cart.GetElements()) 81 | { 82 | driver.RegisterProduct(element.GetName(), element.GetSku(), element.GetCartCount(), element.GetPrice(), i); 83 | sum += (element.GetCartCount()*element.GetPrice()); 84 | i++; 85 | } 86 | double paymentSum; 87 | if (cartSum < sum) 88 | { 89 | int discount = Convert.ToInt32(sum - cartSum); 90 | if (discount <= 1) 91 | discount = 1; 92 | 93 | paymentSum = sum-discount; 94 | } 95 | else 96 | { 97 | paymentSum = sum; 98 | } 99 | driver.SetTaxNumber(tax_id); 100 | driver.PrintTotal(); 101 | driver.RegisterPayment(cartSum, paymentType); 102 | driver.BotIndent(); 103 | driver.CloseDocument(); 104 | } 105 | 106 | public void OpenSession() 107 | { 108 | driver.OpenSession(); 109 | } 110 | 111 | public void CloseSession() 112 | { 113 | driver.CloseSession(); 114 | } 115 | 116 | public bool IsSessionOpen() 117 | { 118 | return driver.IsSessionOpen(); 119 | } 120 | 121 | public List GetStatus() 122 | { 123 | return driver.GetStatuses(); 124 | } 125 | 126 | public void SetTax(byte setTax_id) 127 | { 128 | tax_id = setTax_id; 129 | } 130 | 131 | public void TopIndent() 132 | { 133 | driver.PrintString(""); 134 | driver.PrintString(""); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /drivers/PiritLib.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace DvizhSeller.drivers 5 | { 6 | public class PiritLib 7 | { 8 | [StructLayout(LayoutKind.Sequential)] 9 | public unsafe struct MData 10 | { 11 | public int errCode; 12 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] 13 | public byte[] data; 14 | public int dataLength; 15 | } 16 | 17 | //openPort 18 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 19 | public static extern int openPort(string fileName, int speed); 20 | 21 | //commandStart 22 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 23 | public static extern int commandStart(); 24 | 25 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 26 | public static extern int libAddDiscount(byte typeDiscount, string nameDiscount, int sum); 27 | 28 | //libSubTotal 29 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 30 | public static extern int libSubTotal(); 31 | 32 | //scrollPaper 33 | [DllImport("PiritLib.dll")] 34 | public static extern int scrollPaper(); 35 | 36 | //closePort 37 | [DllImport("PiritLib.dll")] 38 | public static extern int closePort(); 39 | 40 | //libAddPayment 41 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 42 | public static extern int libAddPayment(byte typePayment, long sum, string infoStr); 43 | 44 | //libAddPaymentD 45 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 46 | public static extern int libAddPaymentD(byte typePayment, double sum, string infoStr); 47 | 48 | //libOpenDocument 49 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 50 | public static extern int libOpenDocument(byte type, byte numDepart, string nameCashier, int docNumber); 51 | 52 | //libPrintString 53 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 54 | public static extern int libPrintString(string textStr, string attribute); 55 | 56 | //libCloseDocument 57 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 58 | public static extern IntPtr libCloseDocument(ref MData data, byte cutPaper); 59 | 60 | //libCloseDocument 61 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 62 | public static extern int libDoCheckCorrection(string nameCashier, double cash, double cashless, byte correctionFlags); 63 | 64 | //libPrintZReport 65 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 66 | public static extern int libPrintZReport(string nameCashier, int options); 67 | 68 | //libOpenShift 69 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 70 | public static extern int libOpenShift(string nameCashier); 71 | 72 | //getStatusFlags 73 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 74 | public static extern int getStatusFlags([Out] out int fatalStatus, [Out] out int currentFlagsStatus, [Out] out int documentStatus); 75 | 76 | //libGetStatusFlags 77 | [DllImport("PiritLib.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 78 | public static extern IntPtr libGetStatusFlags(ref MData data); 79 | 80 | 81 | //libAddPosition 82 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 83 | public static extern int libAddPosition( 84 | string goodsName, 85 | string barcode, 86 | double quantity, 87 | double price, 88 | byte taxNumber, 89 | int numGoodsPos, 90 | byte numDepart, 91 | byte coefType, 92 | string coefName, 93 | double coefValue 94 | ); 95 | 96 | //libDelPosition 97 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 98 | public static extern int libDelPosition( 99 | string goodsName, 100 | string barcode, 101 | double quantity, 102 | double price, 103 | byte taxNumber, 104 | int numGoodsPos, 105 | byte numDepart 106 | ); 107 | 108 | //libPrintServiceData 109 | [DllImport("PiritLib.dll", CallingConvention = CallingConvention.StdCall)] 110 | public static extern int libPrintServiceData(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | database.db 17 | 18 | 19 | 15 20 | 21 | 22 | р. 23 | 24 | 25 | dvizh.net 26 | 27 | 28 | http 29 | 30 | 31 | demo4 32 | 33 | 34 | k2j33hdj39aqskdenneckksa303kd 35 | 36 | 37 | False 38 | 39 | 40 | True 41 | 42 | 43 | dvizh.net 44 | 45 | 46 | True 47 | 48 | 49 | 1 50 | 51 | 52 | 1 53 | 54 | 55 | 0 56 | 57 | 58 | backend/web/csvapi 59 | 60 | 61 | ? 62 | 63 | 64 | False 65 | 66 | 67 | 1 68 | 69 | 70 | COM5 71 | 72 | 73 | False 74 | 75 | 76 | 1 77 | 78 | 79 | True 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /ClientChooseForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class ClientChooseForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ClientChooseForm)); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.clientsListView = new System.Windows.Forms.ListView(); 34 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 35 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 36 | this.label2 = new System.Windows.Forms.Label(); 37 | this.searchBox = new System.Windows.Forms.TextBox(); 38 | this.SuspendLayout(); 39 | // 40 | // label1 41 | // 42 | this.label1.AutoSize = true; 43 | this.label1.Location = new System.Drawing.Point(131, 320); 44 | this.label1.Name = "label1"; 45 | this.label1.Size = new System.Drawing.Size(130, 13); 46 | this.label1.TabIndex = 0; 47 | this.label1.Text = "Выбор двойным кликом"; 48 | // 49 | // clientsListView 50 | // 51 | this.clientsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 52 | this.columnHeader1, 53 | this.columnHeader2}); 54 | this.clientsListView.FullRowSelect = true; 55 | this.clientsListView.GridLines = true; 56 | this.clientsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; 57 | this.clientsListView.Location = new System.Drawing.Point(12, 38); 58 | this.clientsListView.Name = "clientsListView"; 59 | this.clientsListView.Size = new System.Drawing.Size(406, 277); 60 | this.clientsListView.TabIndex = 1; 61 | this.clientsListView.UseCompatibleStateImageBehavior = false; 62 | this.clientsListView.View = System.Windows.Forms.View.Details; 63 | this.clientsListView.DoubleClick += new System.EventHandler(this.clientsListView_DoubleClick); 64 | // 65 | // columnHeader1 66 | // 67 | this.columnHeader1.Text = "Имя"; 68 | this.columnHeader1.Width = 250; 69 | // 70 | // columnHeader2 71 | // 72 | this.columnHeader2.Text = "Телефон"; 73 | this.columnHeader2.Width = 150; 74 | // 75 | // label2 76 | // 77 | this.label2.AutoSize = true; 78 | this.label2.Location = new System.Drawing.Point(12, 12); 79 | this.label2.Name = "label2"; 80 | this.label2.Size = new System.Drawing.Size(39, 13); 81 | this.label2.TabIndex = 2; 82 | this.label2.Text = "Поиск"; 83 | // 84 | // searchBox 85 | // 86 | this.searchBox.Location = new System.Drawing.Point(58, 12); 87 | this.searchBox.Name = "searchBox"; 88 | this.searchBox.Size = new System.Drawing.Size(360, 20); 89 | this.searchBox.TabIndex = 3; 90 | this.searchBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); 91 | // 92 | // ClientChooseForm 93 | // 94 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 95 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 96 | this.ClientSize = new System.Drawing.Size(430, 342); 97 | this.Controls.Add(this.searchBox); 98 | this.Controls.Add(this.label2); 99 | this.Controls.Add(this.clientsListView); 100 | this.Controls.Add(this.label1); 101 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 102 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 103 | this.MaximizeBox = false; 104 | this.MinimizeBox = false; 105 | this.Name = "ClientChooseForm"; 106 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 107 | this.Text = "Выбор клиента"; 108 | this.TopMost = true; 109 | this.Load += new System.EventHandler(this.ClientsForm_Load); 110 | this.ResumeLayout(false); 111 | this.PerformLayout(); 112 | 113 | } 114 | 115 | #endregion 116 | 117 | private System.Windows.Forms.Label label1; 118 | private System.Windows.Forms.ListView clientsListView; 119 | private System.Windows.Forms.ColumnHeader columnHeader1; 120 | private System.Windows.Forms.ColumnHeader columnHeader2; 121 | private System.Windows.Forms.Label label2; 122 | private System.Windows.Forms.TextBox searchBox; 123 | } 124 | } -------------------------------------------------------------------------------- /FiscalTestForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class FiscalTestForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FiscalTestForm)); 32 | this.textBox = new System.Windows.Forms.TextBox(); 33 | this.printText = new System.Windows.Forms.Button(); 34 | this.labelStatus = new System.Windows.Forms.Label(); 35 | this.label1 = new System.Windows.Forms.Label(); 36 | this.button1 = new System.Windows.Forms.Button(); 37 | this.button2 = new System.Windows.Forms.Button(); 38 | this.SuspendLayout(); 39 | // 40 | // textBox 41 | // 42 | this.textBox.Location = new System.Drawing.Point(12, 121); 43 | this.textBox.Name = "textBox"; 44 | this.textBox.Size = new System.Drawing.Size(187, 20); 45 | this.textBox.TabIndex = 0; 46 | this.textBox.Text = "Тестовая печать"; 47 | // 48 | // printText 49 | // 50 | this.printText.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 51 | this.printText.Location = new System.Drawing.Point(205, 119); 52 | this.printText.Name = "printText"; 53 | this.printText.Size = new System.Drawing.Size(75, 23); 54 | this.printText.TabIndex = 1; 55 | this.printText.Text = "Печать"; 56 | this.printText.UseVisualStyleBackColor = true; 57 | this.printText.Click += new System.EventHandler(this.printText_Click); 58 | // 59 | // labelStatus 60 | // 61 | this.labelStatus.AutoSize = true; 62 | this.labelStatus.Location = new System.Drawing.Point(169, 206); 63 | this.labelStatus.Name = "labelStatus"; 64 | this.labelStatus.Size = new System.Drawing.Size(10, 13); 65 | this.labelStatus.TabIndex = 2; 66 | this.labelStatus.Text = "-"; 67 | // 68 | // label1 69 | // 70 | this.label1.AutoSize = true; 71 | this.label1.Location = new System.Drawing.Point(122, 206); 72 | this.label1.Name = "label1"; 73 | this.label1.Size = new System.Drawing.Size(44, 13); 74 | this.label1.TabIndex = 3; 75 | this.label1.Text = "Статус:"; 76 | // 77 | // button1 78 | // 79 | this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 80 | this.button1.Location = new System.Drawing.Point(12, 30); 81 | this.button1.Name = "button1"; 82 | this.button1.Size = new System.Drawing.Size(268, 23); 83 | this.button1.TabIndex = 4; 84 | this.button1.Text = "Печать системной информации"; 85 | this.button1.UseVisualStyleBackColor = true; 86 | this.button1.Click += new System.EventHandler(this.button1_Click); 87 | // 88 | // button2 89 | // 90 | this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 91 | this.button2.Location = new System.Drawing.Point(12, 73); 92 | this.button2.Name = "button2"; 93 | this.button2.Size = new System.Drawing.Size(268, 23); 94 | this.button2.TabIndex = 5; 95 | this.button2.Text = "Печать отчета"; 96 | this.button2.UseVisualStyleBackColor = true; 97 | this.button2.Click += new System.EventHandler(this.button2_Click); 98 | // 99 | // FiscalTestForm 100 | // 101 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 102 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 103 | this.ClientSize = new System.Drawing.Size(298, 228); 104 | this.Controls.Add(this.button2); 105 | this.Controls.Add(this.button1); 106 | this.Controls.Add(this.label1); 107 | this.Controls.Add(this.labelStatus); 108 | this.Controls.Add(this.printText); 109 | this.Controls.Add(this.textBox); 110 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 111 | this.MaximizeBox = false; 112 | this.MinimizeBox = false; 113 | this.Name = "FiscalTestForm"; 114 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 115 | this.Text = "Тестирование печати"; 116 | this.Load += new System.EventHandler(this.FiscalTestForm_Load); 117 | this.ResumeLayout(false); 118 | this.PerformLayout(); 119 | 120 | } 121 | 122 | #endregion 123 | 124 | private System.Windows.Forms.TextBox textBox; 125 | private System.Windows.Forms.Button printText; 126 | private System.Windows.Forms.Label labelStatus; 127 | private System.Windows.Forms.Label label1; 128 | private System.Windows.Forms.Button button1; 129 | private System.Windows.Forms.Button button2; 130 | } 131 | } -------------------------------------------------------------------------------- /drivers/VikiPrint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using System.IO; 8 | 9 | namespace DvizhSeller.drivers 10 | { 11 | public class VikiPrint : PiritLib, FiscalInterface 12 | { 13 | private string cashierName = "Unknow"; 14 | private int docNumber = 1; 15 | private byte numDepart = 1; 16 | private List statuses; 17 | private byte taxNumber = 1; 18 | string portName; 19 | int portSpeed; 20 | 21 | public const int DOC_TYPE_SERVICE = 1; //For print texts 22 | public const int DOC_TYPE_REGISTER = 2; //For fiscal registration 23 | public const int DOC_TYPE_RETURN = 3; 24 | public const int DOC_TYPE_INCOME = 4; 25 | public const int DOC_TYPE_OUTCOME = 5; 26 | public const int DOC_TYPE_BUY = 6; 27 | public const int DOC_TYPE_ANNULATE = 7; 28 | 29 | public VikiPrint(string setPortName, int setPortSpeed) 30 | { 31 | portName = setPortName; 32 | portSpeed = setPortSpeed; 33 | 34 | taxNumber = Convert.ToByte(Properties.Settings.Default.taxType); 35 | 36 | int result = openPort(portName, portSpeed); 37 | 38 | //commandStart(); 39 | 40 | statuses = new List(); 41 | } 42 | 43 | public bool Ready() 44 | { 45 | int fatalStatus, currentFlagsStatus, documentStatus; 46 | int flagsStatus = getStatusFlags(out fatalStatus, out currentFlagsStatus, out documentStatus); 47 | 48 | if (flagsStatus == 0) 49 | return true; 50 | else 51 | return false; 52 | } 53 | 54 | public void OpenDocument(byte type) 55 | { 56 | libOpenDocument(type, numDepart, cashierName, docNumber); 57 | } 58 | 59 | public void CloseDocument() 60 | { 61 | MData test = new MData(); 62 | libCloseDocument(ref test, 1); 63 | } 64 | 65 | public List GetStatuses() 66 | { 67 | return statuses; 68 | } 69 | 70 | public void SetTaxNumber(byte number) 71 | { 72 | taxNumber = number; 73 | } 74 | 75 | public void SetCashierName(string name) 76 | { 77 | cashierName = ConvertTo866(name); 78 | } 79 | 80 | public void SetNumDepart(byte number) 81 | { 82 | numDepart = number; 83 | } 84 | 85 | public void SetDocNumber(int number) 86 | { 87 | docNumber = number; 88 | } 89 | 90 | public void ScrollPaper() 91 | { 92 | scrollPaper(); 93 | } 94 | 95 | public void PrintString(string text) 96 | { 97 | libPrintString(text, null); 98 | 99 | MData test = new MData(); 100 | libCloseDocument(ref test, 1); 101 | } 102 | 103 | public void RegisterProduct(string name, string barcode, double quantity, double price, int numPos = 1) 104 | { 105 | libAddPosition(ConvertTo866(name), ConvertTo866(barcode), quantity, price, taxNumber, numPos, numDepart, 0, "", 0); 106 | } 107 | 108 | public void AnnulateProduct(string name, double quantity, double price) 109 | { 110 | int numPos = 1; 111 | libAddPosition(ConvertTo866(name), ConvertTo866(name), quantity, price, taxNumber, numPos, numDepart, 0, "", 0); 112 | } 113 | 114 | public void Storning(string name, double quantity, double price) 115 | { 116 | int numPos = 1; 117 | libAddPosition(ConvertTo866(name), ConvertTo866(name), quantity, price, taxNumber, numPos, numDepart, 0, "", 0); 118 | } 119 | 120 | public void RegisterPayment(double sum, byte type = 0) 121 | { 122 | int result = libAddPaymentD(type, sum, ""); 123 | } 124 | 125 | public void PrintTotal() 126 | { 127 | libSubTotal(); 128 | } 129 | 130 | public void RegisterDiscount(byte type, string nameDiscount, int sum) 131 | { 132 | libAddDiscount(type, nameDiscount, sum); 133 | } 134 | 135 | public void PrintServiceData() 136 | { 137 | libPrintServiceData(); 138 | } 139 | 140 | public void OpenSession() 141 | { 142 | libOpenShift(cashierName); 143 | } 144 | 145 | public void CloseSession() 146 | { 147 | libPrintZReport(cashierName, 0); 148 | } 149 | 150 | public bool IsSessionOpen() 151 | { 152 | int fatalStatus, currentFlagsStatus, documentStatus; 153 | int flagsStatus = getStatusFlags(out fatalStatus, out currentFlagsStatus, out documentStatus); 154 | 155 | //MessageBox.Show(flagsStatus.ToString() + '-' + fatalStatus.ToString() + '-' + currentFlagsStatus.ToString() + '-' + documentStatus.ToString()); 156 | 157 | if (flagsStatus == 0) 158 | { 159 | if (currentFlagsStatus == 12) 160 | { 161 | MessageBox.Show("Смена длится более 24 часов. Перезапустите смену."); 162 | return true; 163 | } 164 | 165 | if (currentFlagsStatus == 4) 166 | return true; 167 | else 168 | return false; 169 | } 170 | 171 | return false; 172 | } 173 | 174 | private string ConvertTo866(string str) 175 | { 176 | return System.Text.Encoding.Default.GetString(Encoding.Convert(Encoding.GetEncoding("windows-1251"), Encoding.GetEncoding("CP866"), Encoding.GetEncoding("windows-1251").GetBytes(str))); 177 | } 178 | 179 | ~VikiPrint() 180 | { 181 | closePort(); 182 | } 183 | 184 | public void BotIndent() 185 | { 186 | 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\placeholder.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /ShopBookForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class ShopBookForm : Form 14 | { 15 | services.Database db = new services.Database(); 16 | 17 | tools.ProductProvider productsProvider = new tools.ProductProvider(); 18 | tools.ProductProvider searchProductsProvider = new tools.ProductProvider(); 19 | tools.CategoryProvider categoriesProvider = new tools.CategoryProvider(); 20 | 21 | entities.Product selectedProduct = null; 22 | 23 | repositories.Product products; 24 | repositories.Category categories; 25 | 26 | services.DataMapper dataMapper; 27 | 28 | CashierForm cashierForm; 29 | 30 | public ShopBookForm(CashierForm setCashierForm) 31 | { 32 | cashierForm = setCashierForm; 33 | 34 | InitializeComponent(); 35 | 36 | SetProductsList(); 37 | 38 | foreach (entities.Product product in products.GetList()) 39 | { 40 | productsProvider.Add(product); 41 | } 42 | 43 | foreach (entities.Category category in categories.GetList()) 44 | { 45 | categoriesProvider.Add(category); 46 | } 47 | 48 | if(productsProvider.Count > 0) 49 | { 50 | SelectFormProduct(productsProvider[0]); 51 | } 52 | 53 | productsGridView.DataSource = productsProvider; 54 | 55 | productsGridView.Update(); 56 | } 57 | 58 | public void SetProductsList() 59 | { 60 | products = new repositories.Product(db); 61 | categories = new repositories.Category(db); 62 | 63 | dataMapper = new services.DataMapper(db); 64 | dataMapper.FillCategories(categories); 65 | dataMapper.FillProducts(products, categories); 66 | } 67 | 68 | private void searchBox_KeyDown(object sender, KeyEventArgs e) 69 | { 70 | if (e.KeyCode == Keys.Enter) 71 | { 72 | if (searchBox.Text == "") 73 | productsGridView.DataSource = productsProvider; 74 | else 75 | { 76 | searchProductsProvider = new tools.ProductProvider(); 77 | 78 | foreach (entities.Product product in products.FindByString(searchBox.Text)) 79 | { 80 | searchProductsProvider.Add(product); 81 | } 82 | 83 | productsGridView.DataSource = searchProductsProvider; 84 | } 85 | } 86 | } 87 | 88 | private void searchBox_Click(object sender, EventArgs e) 89 | { 90 | if (searchBox.Text == "Название или штрихкод") 91 | { 92 | searchBox.Text = ""; 93 | } 94 | } 95 | 96 | private void SelectFormProduct(entities.Product product) 97 | { 98 | productsTabControl.Visible = true; 99 | selectedProduct = product; 100 | productNameBox.Text = product.GetName(); 101 | productPriceBox.Text = product.GetPrice().ToString(); 102 | productSkuBox.Text = product.GetSku(); 103 | 104 | productPrice.Text = product.GetPrice().ToString() + Properties.Settings.Default.currency; 105 | productSku.Text = product.GetSku(); 106 | productCount.Value = 1; 107 | productAmount.Text = product.GetAmount().ToString(); 108 | productPicture.ImageLocation = product.GetImage(); 109 | } 110 | 111 | private void productsGridView_CellClick(object sender, DataGridViewCellEventArgs e) 112 | { 113 | SelectFormProduct(productsProvider[productsGridView.CurrentCell.RowIndex]); 114 | } 115 | 116 | private void saveButton_Click(object sender, EventArgs e) 117 | { 118 | if(selectedProduct != null) 119 | { 120 | selectedProduct.SetName(productNameBox.Text); 121 | selectedProduct.SetPrice(Convert.ToDouble(productPriceBox.Text)); 122 | selectedProduct.SetSku(productSkuBox.Text); 123 | 124 | products.SaveWithSql(selectedProduct); 125 | 126 | MessageBox.Show("Сохранено"); 127 | } 128 | 129 | productsGridView.Update(); 130 | productsGridView.Focus(); 131 | } 132 | 133 | private void deleteButton_Click(object sender, EventArgs e) 134 | { 135 | if (selectedProduct != null) 136 | { 137 | products.DeleteWithSql(selectedProduct); 138 | 139 | productsProvider.Remove(selectedProduct); 140 | } 141 | 142 | productsGridView.Update(); 143 | productsGridView.Focus(); 144 | 145 | productsTabControl.Visible = false; 146 | } 147 | 148 | private bool AddProduct() 149 | { 150 | if (addProductNameBox.Text == "") 151 | { 152 | MessageBox.Show("Имя обязательно"); 153 | 154 | return false; 155 | } 156 | 157 | if (addProductPriceBox.Text == "") 158 | { 159 | MessageBox.Show("Цена обязательна"); 160 | 161 | return false; 162 | } 163 | 164 | entities.Product product = new entities.Product(0, addProductSkuBox.Text, addProductNameBox.Text, Convert.ToDouble(addProductPriceBox.Text)); 165 | 166 | products.SaveWithSql(product); 167 | 168 | productsProvider.Add(product); 169 | 170 | productsGridView.Update(); 171 | 172 | addProductNameBox.Text = ""; 173 | addProductSkuBox.Text = ""; 174 | addProductPriceBox.Text = ""; 175 | 176 | SetProductsList(); 177 | 178 | MessageBox.Show("Сохранено"); 179 | 180 | return true; 181 | } 182 | 183 | private void PutToCart() 184 | { 185 | cashierForm.PutToCart(selectedProduct, Convert.ToInt32(productCount.Value)); 186 | productCount.Value = 1; 187 | } 188 | 189 | private void addProdutButton_Click(object sender, EventArgs e) 190 | { 191 | AddProduct(); 192 | } 193 | 194 | private void toCartButton_Click(object sender, EventArgs e) 195 | { 196 | PutToCart(); 197 | } 198 | 199 | private void ShopBookForm_Load(object sender, EventArgs e) 200 | { 201 | 202 | } 203 | 204 | private void ShopBookForm_FormClosing(object sender, FormClosingEventArgs e) 205 | { 206 | cashierForm.SetProductsList(); 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /FreeSaleForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class FreeSaleForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FreeSaleForm)); 32 | this.nameBox = new System.Windows.Forms.TextBox(); 33 | this.priceBox = new System.Windows.Forms.TextBox(); 34 | this.nameLabel = new System.Windows.Forms.Label(); 35 | this.label1 = new System.Windows.Forms.Label(); 36 | this.label2 = new System.Windows.Forms.Label(); 37 | this.label3 = new System.Windows.Forms.Label(); 38 | this.productCount = new System.Windows.Forms.NumericUpDown(); 39 | ((System.ComponentModel.ISupportInitialize)(this.productCount)).BeginInit(); 40 | this.SuspendLayout(); 41 | // 42 | // nameBox 43 | // 44 | this.nameBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 45 | this.nameBox.Location = new System.Drawing.Point(12, 25); 46 | this.nameBox.Name = "nameBox"; 47 | this.nameBox.Size = new System.Drawing.Size(305, 40); 48 | this.nameBox.TabIndex = 11; 49 | this.nameBox.Text = "Свободная цена"; 50 | this.nameBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FreeSaleForm_KeyDown); 51 | // 52 | // priceBox 53 | // 54 | this.priceBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 55 | this.priceBox.Location = new System.Drawing.Point(323, 25); 56 | this.priceBox.Name = "priceBox"; 57 | this.priceBox.Size = new System.Drawing.Size(108, 40); 58 | this.priceBox.TabIndex = 12; 59 | this.priceBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FreeSaleForm_KeyDown); 60 | // 61 | // nameLabel 62 | // 63 | this.nameLabel.AutoSize = true; 64 | this.nameLabel.Location = new System.Drawing.Point(12, 9); 65 | this.nameLabel.Name = "nameLabel"; 66 | this.nameLabel.Size = new System.Drawing.Size(86, 13); 67 | this.nameLabel.TabIndex = 13; 68 | this.nameLabel.Text = "Наименование:"; 69 | // 70 | // label1 71 | // 72 | this.label1.AutoSize = true; 73 | this.label1.Location = new System.Drawing.Point(320, 9); 74 | this.label1.Name = "label1"; 75 | this.label1.Size = new System.Drawing.Size(36, 13); 76 | this.label1.TabIndex = 14; 77 | this.label1.Text = "Цена:"; 78 | // 79 | // label2 80 | // 81 | this.label2.AutoSize = true; 82 | this.label2.Location = new System.Drawing.Point(101, 85); 83 | this.label2.Name = "label2"; 84 | this.label2.Size = new System.Drawing.Size(255, 13); 85 | this.label2.TabIndex = 15; 86 | this.label2.Text = "Нажмите Enter, чтобы положить товар в корзину"; 87 | // 88 | // label3 89 | // 90 | this.label3.AutoSize = true; 91 | this.label3.Location = new System.Drawing.Point(434, 9); 92 | this.label3.Name = "label3"; 93 | this.label3.Size = new System.Drawing.Size(44, 13); 94 | this.label3.TabIndex = 17; 95 | this.label3.Text = "Кол-во:"; 96 | // 97 | // productCount 98 | // 99 | this.productCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.75F); 100 | this.productCount.Location = new System.Drawing.Point(438, 26); 101 | this.productCount.Name = "productCount"; 102 | this.productCount.Size = new System.Drawing.Size(62, 39); 103 | this.productCount.TabIndex = 18; 104 | this.productCount.Value = new decimal(new int[] { 105 | 1, 106 | 0, 107 | 0, 108 | 0}); 109 | this.productCount.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FreeSaleForm_KeyDown); 110 | // 111 | // FreeSaleForm 112 | // 113 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 114 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 115 | this.ClientSize = new System.Drawing.Size(507, 107); 116 | this.Controls.Add(this.productCount); 117 | this.Controls.Add(this.label3); 118 | this.Controls.Add(this.label2); 119 | this.Controls.Add(this.label1); 120 | this.Controls.Add(this.nameLabel); 121 | this.Controls.Add(this.priceBox); 122 | this.Controls.Add(this.nameBox); 123 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 124 | this.MaximizeBox = false; 125 | this.MinimizeBox = false; 126 | this.Name = "FreeSaleForm"; 127 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 128 | this.Text = "Свободная продажа"; 129 | this.Load += new System.EventHandler(this.FreeSaleForm_Load); 130 | this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FreeSaleForm_KeyDown); 131 | ((System.ComponentModel.ISupportInitialize)(this.productCount)).EndInit(); 132 | this.ResumeLayout(false); 133 | this.PerformLayout(); 134 | 135 | } 136 | 137 | #endregion 138 | 139 | private System.Windows.Forms.TextBox nameBox; 140 | private System.Windows.Forms.TextBox priceBox; 141 | private System.Windows.Forms.Label nameLabel; 142 | private System.Windows.Forms.Label label1; 143 | private System.Windows.Forms.Label label2; 144 | private System.Windows.Forms.Label label3; 145 | private System.Windows.Forms.NumericUpDown productCount; 146 | } 147 | } -------------------------------------------------------------------------------- /SettingsForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace DvizhSeller 12 | { 13 | public partial class SettingsForm : Form 14 | { 15 | CashierForm cashierForm; 16 | 17 | services.Database db = new services.Database(); 18 | 19 | int loadedFiscalType; 20 | 21 | repositories.Cashbox cashboxes; 22 | 23 | services.DataMapper dataMapper; 24 | 25 | public SettingsForm(CashierForm setCashierForm) 26 | { 27 | cashierForm = setCashierForm; 28 | 29 | cashboxes = new repositories.Cashbox(db); 30 | 31 | dataMapper = new services.DataMapper(db); 32 | dataMapper.FillCashboxes(cashboxes); 33 | 34 | InitializeComponent(); 35 | } 36 | 37 | private void renderFiscalSettings() 38 | { 39 | if(fiscal.Checked) 40 | fiscalSettings.Enabled = true; 41 | else 42 | fiscalSettings.Enabled = false; 43 | 44 | if (fiscalDriverTypeBox.SelectedIndex == 0) 45 | { 46 | fiscalComPortBox.Enabled = true; 47 | atolSettingsButton.Enabled = false; 48 | } 49 | 50 | if (fiscalDriverTypeBox.SelectedIndex == 1) 51 | { 52 | fiscalComPortBox.Enabled = false; 53 | atolSettingsButton.Enabled = true; 54 | } 55 | } 56 | 57 | private void SettingsForm_Load(object sender, EventArgs e) 58 | { 59 | protocolBox.Text = Properties.Settings.Default.protocol; 60 | hostBox.Text = Properties.Settings.Default.host; 61 | dbFileBox.Text = Properties.Settings.Default.dbFile; 62 | clientBox.Text = Properties.Settings.Default.client; 63 | currencyBox.Text = Properties.Settings.Default.currency; 64 | tokenBox.Text = Properties.Settings.Default.token; 65 | online.Checked = Properties.Settings.Default.online; 66 | fiscal.Checked = Properties.Settings.Default.fiscal; 67 | testMode.Checked = Properties.Settings.Default.testMode; 68 | barcodescaner.Checked = Properties.Settings.Default.barcodescaner; 69 | checkNoteBox.Text = Properties.Settings.Default.checkNote; 70 | roundingTypeBox.SelectedIndex = Properties.Settings.Default.roundingType; 71 | roundingBox.Text = Properties.Settings.Default.rounding.ToString(); 72 | fiscalComPortBox.Text = Properties.Settings.Default.fiscalComPort.ToString(); 73 | autoOpenTabletBox.Checked = Properties.Settings.Default.autoOpenTablet; 74 | autoStartWebServerBox.Checked = Properties.Settings.Default.autoStartWebServer; 75 | taxBox.Text = Properties.Settings.Default.taxType.ToString(); 76 | 77 | Item vikiItem = new Item("VikiPrint (Пирит)", 1); 78 | fiscalDriverTypeBox.Items.Add(vikiItem); 79 | 80 | Item atolItem = new Item("АТОЛ", 2); 81 | fiscalDriverTypeBox.Items.Add(atolItem); 82 | 83 | foreach (entities.Cashbox cashbox in cashboxes.GetList()) 84 | { 85 | Item item = new Item(cashbox.GetName(), cashbox.GetId()); 86 | 87 | cashboxId.Items.Add(item); 88 | 89 | if(cashbox.GetId() == Properties.Settings.Default.cashboxId) 90 | { 91 | cashboxId.SelectedItem = item; 92 | } 93 | } 94 | 95 | if (Properties.Settings.Default.fiscalDriverType == 0) 96 | fiscalDriverTypeBox.SelectedItem = vikiItem; 97 | else 98 | fiscalDriverTypeBox.SelectedItem = atolItem; 99 | 100 | loadedFiscalType = fiscalDriverTypeBox.SelectedIndex; 101 | 102 | renderFiscalSettings(); 103 | } 104 | 105 | private void settingsSave_Click(object sender, EventArgs e) 106 | { 107 | Properties.Settings.Default.protocol = protocolBox.Text; 108 | Properties.Settings.Default.host = hostBox.Text; 109 | Properties.Settings.Default.client = clientBox.Text; 110 | Properties.Settings.Default.currency = currencyBox.Text; 111 | Properties.Settings.Default.token = tokenBox.Text; 112 | Properties.Settings.Default.online = online.Checked; 113 | Properties.Settings.Default.fiscal = fiscal.Checked; 114 | Properties.Settings.Default.testMode = testMode.Checked; 115 | Properties.Settings.Default.barcodescaner = barcodescaner.Checked; 116 | Properties.Settings.Default.checkNote = checkNoteBox.Text; 117 | Properties.Settings.Default.roundingType = roundingTypeBox.SelectedIndex; 118 | Properties.Settings.Default.rounding = Convert.ToInt16(roundingBox.Text); 119 | Properties.Settings.Default.dbFile = dbFileBox.Text; 120 | Properties.Settings.Default.fiscalComPort = fiscalComPortBox.Text; 121 | Properties.Settings.Default.fiscalDriverType = fiscalDriverTypeBox.SelectedIndex; 122 | Properties.Settings.Default.autoOpenTablet = autoOpenTabletBox.Checked; 123 | Properties.Settings.Default.autoStartWebServer = autoStartWebServerBox.Checked; 124 | Properties.Settings.Default.taxType = Convert.ToInt16(taxBox.Text); 125 | 126 | object selectedItem = cashboxId.SelectedItem; 127 | Properties.Settings.Default.cashboxId = Convert.ToInt32(selectedItem.GetHashCode()); 128 | 129 | if (fiscal.Checked) 130 | cashierForm.ActivateFiscal(); 131 | else 132 | cashierForm.DeactivateFiscal(); 133 | 134 | Properties.Settings.Default.Save(); 135 | 136 | if (Properties.Settings.Default.fiscalDriverType != loadedFiscalType) 137 | MessageBox.Show("Перезапустите программу, чтобы сменить драйвер."); 138 | 139 | savingInfo.Text = "Сохранено."; 140 | } 141 | 142 | private class Item 143 | { 144 | public string Name; 145 | public int Value; 146 | 147 | public Item(string name, int value) 148 | { 149 | Name = name; Value = value; 150 | } 151 | 152 | public override string ToString() 153 | { 154 | return Name; 155 | } 156 | 157 | public override int GetHashCode() 158 | { 159 | return Value; 160 | } 161 | } 162 | 163 | private void fiscal_CheckedChanged(object sender, EventArgs e) 164 | { 165 | renderFiscalSettings(); 166 | } 167 | 168 | private void fiscalDriverTypeBox_SelectedValueChanged(object sender, EventArgs e) 169 | { 170 | renderFiscalSettings(); 171 | } 172 | 173 | private void atolSettingsButton_Click(object sender, EventArgs e) 174 | { 175 | try 176 | { 177 | FprnM1C.IFprnM45 cmd = new FprnM1C.FprnM45(); 178 | cmd.ShowProperties(); 179 | } 180 | catch (Exception) 181 | { 182 | MessageBox.Show("Драйвер не установлен или поврежден. Скачайте и установите драйвера оборудования с сайта dvizh.net!"); 183 | } 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /AboutForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class AboutForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutForm)); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.label3 = new System.Windows.Forms.Label(); 35 | this.label4 = new System.Windows.Forms.Label(); 36 | this.montanaMail = new System.Windows.Forms.LinkLabel(); 37 | this.label5 = new System.Windows.Forms.Label(); 38 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 39 | this.dvizhLink = new System.Windows.Forms.LinkLabel(); 40 | this.label6 = new System.Windows.Forms.Label(); 41 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 42 | this.SuspendLayout(); 43 | // 44 | // label1 45 | // 46 | this.label1.AutoSize = true; 47 | this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 48 | this.label1.Location = new System.Drawing.Point(12, 9); 49 | this.label1.Name = "label1"; 50 | this.label1.Size = new System.Drawing.Size(212, 25); 51 | this.label1.TabIndex = 0; 52 | this.label1.Text = "Dvizh.APM.Кассир"; 53 | // 54 | // label2 55 | // 56 | this.label2.AutoSize = true; 57 | this.label2.Location = new System.Drawing.Point(116, 87); 58 | this.label2.Name = "label2"; 59 | this.label2.Size = new System.Drawing.Size(47, 13); 60 | this.label2.TabIndex = 1; 61 | this.label2.Text = "Вендор:"; 62 | // 63 | // label3 64 | // 65 | this.label3.AutoSize = true; 66 | this.label3.Location = new System.Drawing.Point(14, 87); 67 | this.label3.Name = "label3"; 68 | this.label3.Size = new System.Drawing.Size(74, 13); 69 | this.label3.TabIndex = 2; 70 | this.label3.Text = "Версия: 1.0.0"; 71 | // 72 | // label4 73 | // 74 | this.label4.AutoSize = true; 75 | this.label4.Location = new System.Drawing.Point(14, 100); 76 | this.label4.Name = "label4"; 77 | this.label4.Size = new System.Drawing.Size(96, 13); 78 | this.label4.TabIndex = 3; 79 | this.label4.Text = "Связь с автором:"; 80 | // 81 | // montanaMail 82 | // 83 | this.montanaMail.AutoSize = true; 84 | this.montanaMail.Location = new System.Drawing.Point(116, 113); 85 | this.montanaMail.Name = "montanaMail"; 86 | this.montanaMail.Size = new System.Drawing.Size(110, 13); 87 | this.montanaMail.TabIndex = 4; 88 | this.montanaMail.TabStop = true; 89 | this.montanaMail.Text = "admin@nethammer.ru"; 90 | this.montanaMail.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.montanaMail_LinkClicked); 91 | // 92 | // label5 93 | // 94 | this.label5.AutoSize = true; 95 | this.label5.Location = new System.Drawing.Point(116, 100); 96 | this.label5.Name = "label5"; 97 | this.label5.Size = new System.Drawing.Size(76, 13); 98 | this.label5.TabIndex = 6; 99 | this.label5.Text = "Tony Montana"; 100 | // 101 | // pictureBox1 102 | // 103 | this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); 104 | this.pictureBox1.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.InitialImage"))); 105 | this.pictureBox1.Location = new System.Drawing.Point(17, 140); 106 | this.pictureBox1.Name = "pictureBox1"; 107 | this.pictureBox1.Size = new System.Drawing.Size(259, 259); 108 | this.pictureBox1.TabIndex = 5; 109 | this.pictureBox1.TabStop = false; 110 | this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); 111 | // 112 | // dvizhLink 113 | // 114 | this.dvizhLink.AutoSize = true; 115 | this.dvizhLink.Location = new System.Drawing.Point(169, 87); 116 | this.dvizhLink.Name = "dvizhLink"; 117 | this.dvizhLink.Size = new System.Drawing.Size(86, 13); 118 | this.dvizhLink.TabIndex = 8; 119 | this.dvizhLink.TabStop = true; 120 | this.dvizhLink.Text = "http://dvizh.net/"; 121 | this.dvizhLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.dvizhLink_LinkClicked); 122 | // 123 | // label6 124 | // 125 | this.label6.AutoSize = true; 126 | this.label6.Location = new System.Drawing.Point(17, 38); 127 | this.label6.Name = "label6"; 128 | this.label6.Size = new System.Drawing.Size(172, 13); 129 | this.label6.TabIndex = 9; 130 | this.label6.Text = "Программа для работы кассира"; 131 | // 132 | // AboutForm 133 | // 134 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 135 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 136 | this.ClientSize = new System.Drawing.Size(294, 413); 137 | this.Controls.Add(this.label6); 138 | this.Controls.Add(this.dvizhLink); 139 | this.Controls.Add(this.label5); 140 | this.Controls.Add(this.pictureBox1); 141 | this.Controls.Add(this.montanaMail); 142 | this.Controls.Add(this.label4); 143 | this.Controls.Add(this.label3); 144 | this.Controls.Add(this.label2); 145 | this.Controls.Add(this.label1); 146 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 147 | this.MaximizeBox = false; 148 | this.MinimizeBox = false; 149 | this.Name = "AboutForm"; 150 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 151 | this.Text = "О программе"; 152 | this.TopMost = true; 153 | this.Load += new System.EventHandler(this.AboutForm_Load); 154 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 155 | this.ResumeLayout(false); 156 | this.PerformLayout(); 157 | 158 | } 159 | 160 | #endregion 161 | 162 | private System.Windows.Forms.Label label1; 163 | private System.Windows.Forms.Label label2; 164 | private System.Windows.Forms.Label label3; 165 | private System.Windows.Forms.Label label4; 166 | private System.Windows.Forms.LinkLabel montanaMail; 167 | private System.Windows.Forms.PictureBox pictureBox1; 168 | private System.Windows.Forms.Label label5; 169 | private System.Windows.Forms.LinkLabel dvizhLink; 170 | private System.Windows.Forms.Label label6; 171 | } 172 | } -------------------------------------------------------------------------------- /services/DataMapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Data.SQLite; 7 | using System.Windows.Forms; 8 | 9 | namespace DvizhSeller.services 10 | { 11 | class DataMapper 12 | { 13 | Database db; 14 | 15 | public DataMapper(Database setDb) 16 | { 17 | db = setDb; 18 | } 19 | 20 | public bool FillProducts(repositories.Product productRepository, repositories.Category categoryRepository) 21 | { 22 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM product", db.connection); 23 | 24 | SQLiteDataReader reader = command.ExecuteReader(); 25 | 26 | if (reader.HasRows) 27 | { 28 | while (reader.Read()) 29 | { 30 | int id = reader.GetInt32(0); 31 | string sku = reader.GetString(1); 32 | string name = reader.GetString(2); 33 | double price = Convert.ToDouble(reader.GetDecimal(3)); 34 | dynamic category = null; 35 | string image; 36 | int amount; 37 | 38 | if (!reader.IsDBNull(5)) 39 | image = reader.GetString(5); 40 | else 41 | image = null; 42 | 43 | if (!reader.IsDBNull(6)) 44 | amount = reader.GetInt32(6); 45 | else 46 | amount = 0; 47 | 48 | 49 | if (!reader.IsDBNull(4)) 50 | category = categoryRepository.FindOne(reader.GetInt32(4)); 51 | else 52 | category = null; 53 | 54 | entities.Product product = new entities.Product(id, sku, name, price, category, image, amount); 55 | 56 | productRepository.Add(product); 57 | } 58 | } 59 | 60 | reader.Close(); 61 | 62 | return true; 63 | } 64 | 65 | public bool FillCategories(repositories.Category categoryRepository) 66 | { 67 | 68 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM category", db.connection); 69 | 70 | SQLiteDataReader reader = command.ExecuteReader(); 71 | 72 | if (reader.HasRows) 73 | { 74 | while (reader.Read()) 75 | { 76 | entities.Category category = new entities.Category(reader.GetInt32(0), reader.GetString(1)); 77 | categoryRepository.Add(category); 78 | } 79 | } 80 | 81 | reader.Close(); 82 | 83 | return true; 84 | } 85 | 86 | public bool FillClients(repositories.Client clientRepository) 87 | { 88 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM client", db.connection); 89 | 90 | SQLiteDataReader reader = command.ExecuteReader(); 91 | 92 | if (reader.HasRows) 93 | { 94 | while (reader.Read()) 95 | { 96 | string phone; 97 | 98 | if (!reader.IsDBNull(2)) 99 | phone = reader.GetString(2); 100 | else 101 | phone = ""; 102 | 103 | entities.Client client = new entities.Client(reader.GetInt32(0), reader.GetString(1), phone); 104 | clientRepository.Add(client); 105 | } 106 | } 107 | 108 | reader.Close(); 109 | 110 | return true; 111 | } 112 | 113 | public bool FillCashboxes(repositories.Cashbox cashboxRepository) 114 | { 115 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM cashbox", db.connection); 116 | 117 | SQLiteDataReader reader = command.ExecuteReader(); 118 | 119 | if (reader.HasRows) 120 | { 121 | while (reader.Read()) 122 | { 123 | 124 | entities.Cashbox cashbox = new entities.Cashbox(reader.GetInt32(0), reader.GetString(1)); 125 | cashboxRepository.Add(cashbox); 126 | } 127 | } 128 | 129 | reader.Close(); 130 | 131 | return true; 132 | } 133 | 134 | public bool FillCashiers(repositories.Cashier cashierRepository) 135 | { 136 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM cashier", db.connection); 137 | 138 | SQLiteDataReader reader = command.ExecuteReader(); 139 | 140 | if (reader.HasRows) 141 | { 142 | while (reader.Read()) 143 | { 144 | //MessageBox.Show(reader["name"].ToString()); 145 | entities.Cashier cashbox = new entities.Cashier(Convert.ToInt32(reader["id"].ToString()), reader["name"].ToString()); 146 | cashierRepository.Add(cashbox); 147 | } 148 | } 149 | 150 | reader.Close(); 151 | 152 | return true; 153 | } 154 | 155 | public bool FillDiscounts(repositories.Discount discountRepository) 156 | { 157 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM discount", db.connection); 158 | 159 | SQLiteDataReader reader = command.ExecuteReader(); 160 | 161 | if (reader.HasRows) 162 | { 163 | while (reader.Read()) 164 | { 165 | entities.Discount discount = new entities.Discount(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2)); 166 | discountRepository.Add(discount); 167 | } 168 | } 169 | 170 | reader.Close(); 171 | 172 | return true; 173 | } 174 | 175 | public static entities.Order BuildOrder(SQLiteDataReader reader) 176 | { 177 | int dvizhId = 0; 178 | 179 | if (!reader.IsDBNull(1)) 180 | dvizhId = reader.GetInt32(1); 181 | else 182 | dvizhId = 0; 183 | 184 | return new entities.Order( 185 | reader.GetInt32(0), //id 186 | reader.GetString(3), //date 187 | Convert.ToDouble(reader["total"].ToString()), //total 188 | reader.GetInt32(2), //cashier 189 | reader.GetInt32(7), //client 190 | reader.GetInt32(6), //discount 191 | dvizhId //dvizh id 192 | ); 193 | } 194 | 195 | public bool FillOrders(repositories.Order orderRepository) 196 | { 197 | DateTime dt1 = DateTime.Now; 198 | SQLiteCommand command = new SQLiteCommand("SELECT * FROM order_list WHERE cancel_at IS NULL ORDER BY id DESC LIMIT 1000", db.connection); 199 | 200 | SQLiteDataReader reader = command.ExecuteReader(); 201 | 202 | if (reader.HasRows) 203 | { 204 | while (reader.Read()) 205 | { 206 | entities.Order order = BuildOrder(reader); 207 | 208 | orderRepository.Add(order); 209 | } 210 | } 211 | 212 | reader.Close(); 213 | 214 | foreach(entities.Order order in orderRepository.GetList()) 215 | { 216 | SQLiteCommand elementCommand = new SQLiteCommand("SELECT * FROM order_element_list WHERE order_id = " + order.GetId().ToString(), db.connection); 217 | 218 | SQLiteDataReader elementReader = elementCommand.ExecuteReader(); 219 | 220 | if (elementReader.HasRows) 221 | { 222 | while (elementReader.Read()) 223 | { 224 | string cancelAt; 225 | 226 | if (!elementReader.IsDBNull(6)) 227 | cancelAt = elementReader.GetString(6); 228 | else 229 | cancelAt = ""; 230 | 231 | entities.OrderElement element = new entities.OrderElement(elementReader.GetInt32(0), elementReader.GetInt32(1), elementReader.GetString(3), Convert.ToDouble(elementReader.GetDecimal(5)), elementReader.GetInt32(4), cancelAt); 232 | order.AddElement(element); 233 | } 234 | } 235 | 236 | elementReader.Close(); 237 | } 238 | 239 | return true; 240 | } 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /ClientsBookForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class ClientsBookForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ClientsBookForm)); 33 | this.tabControl1 = new System.Windows.Forms.TabControl(); 34 | this.tabPage1 = new System.Windows.Forms.TabPage(); 35 | this.label2 = new System.Windows.Forms.Label(); 36 | this.searchBox = new System.Windows.Forms.TextBox(); 37 | this.clientsGridView = new System.Windows.Forms.DataGridView(); 38 | this.nameDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 39 | this.Amount = new System.Windows.Forms.DataGridViewTextBoxColumn(); 40 | this.tabPage2 = new System.Windows.Forms.TabPage(); 41 | this.label1 = new System.Windows.Forms.Label(); 42 | this.clientProviderBindingSource = new System.Windows.Forms.BindingSource(this.components); 43 | this.tabControl1.SuspendLayout(); 44 | this.tabPage1.SuspendLayout(); 45 | ((System.ComponentModel.ISupportInitialize)(this.clientsGridView)).BeginInit(); 46 | this.tabPage2.SuspendLayout(); 47 | ((System.ComponentModel.ISupportInitialize)(this.clientProviderBindingSource)).BeginInit(); 48 | this.SuspendLayout(); 49 | // 50 | // tabControl1 51 | // 52 | this.tabControl1.Controls.Add(this.tabPage1); 53 | this.tabControl1.Controls.Add(this.tabPage2); 54 | this.tabControl1.Location = new System.Drawing.Point(12, 12); 55 | this.tabControl1.Name = "tabControl1"; 56 | this.tabControl1.SelectedIndex = 0; 57 | this.tabControl1.Size = new System.Drawing.Size(482, 377); 58 | this.tabControl1.TabIndex = 1; 59 | // 60 | // tabPage1 61 | // 62 | this.tabPage1.Controls.Add(this.label2); 63 | this.tabPage1.Controls.Add(this.searchBox); 64 | this.tabPage1.Controls.Add(this.clientsGridView); 65 | this.tabPage1.Location = new System.Drawing.Point(4, 22); 66 | this.tabPage1.Name = "tabPage1"; 67 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 68 | this.tabPage1.Size = new System.Drawing.Size(474, 351); 69 | this.tabPage1.TabIndex = 0; 70 | this.tabPage1.Text = "Клиенты"; 71 | this.tabPage1.UseVisualStyleBackColor = true; 72 | // 73 | // label2 74 | // 75 | this.label2.AutoSize = true; 76 | this.label2.Location = new System.Drawing.Point(6, 11); 77 | this.label2.Name = "label2"; 78 | this.label2.Size = new System.Drawing.Size(42, 13); 79 | this.label2.TabIndex = 2; 80 | this.label2.Text = "Поиск:"; 81 | // 82 | // searchBox 83 | // 84 | this.searchBox.Location = new System.Drawing.Point(54, 8); 85 | this.searchBox.Name = "searchBox"; 86 | this.searchBox.Size = new System.Drawing.Size(414, 20); 87 | this.searchBox.TabIndex = 1; 88 | this.searchBox.Text = "Имя или телефон"; 89 | this.searchBox.Click += new System.EventHandler(this.searchBox_Click); 90 | this.searchBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchBox_KeyDown); 91 | // 92 | // clientsGridView 93 | // 94 | this.clientsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 95 | this.clientsGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 96 | this.nameDataGridViewTextBoxColumn1, 97 | this.Amount}); 98 | this.clientsGridView.Location = new System.Drawing.Point(0, 34); 99 | this.clientsGridView.Name = "clientsGridView"; 100 | this.clientsGridView.ReadOnly = true; 101 | this.clientsGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; 102 | this.clientsGridView.Size = new System.Drawing.Size(470, 311); 103 | this.clientsGridView.TabIndex = 0; 104 | // 105 | // nameDataGridViewTextBoxColumn1 106 | // 107 | this.nameDataGridViewTextBoxColumn1.DataPropertyName = "Name"; 108 | this.nameDataGridViewTextBoxColumn1.HeaderText = "Имя"; 109 | this.nameDataGridViewTextBoxColumn1.Name = "nameDataGridViewTextBoxColumn1"; 110 | this.nameDataGridViewTextBoxColumn1.ReadOnly = true; 111 | this.nameDataGridViewTextBoxColumn1.Width = 260; 112 | // 113 | // Amount 114 | // 115 | this.Amount.DataPropertyName = "Phone"; 116 | this.Amount.HeaderText = "Телефон"; 117 | this.Amount.Name = "Amount"; 118 | this.Amount.ReadOnly = true; 119 | this.Amount.Width = 150; 120 | // 121 | // tabPage2 122 | // 123 | this.tabPage2.Controls.Add(this.label1); 124 | this.tabPage2.Location = new System.Drawing.Point(4, 22); 125 | this.tabPage2.Name = "tabPage2"; 126 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3); 127 | this.tabPage2.Size = new System.Drawing.Size(474, 351); 128 | this.tabPage2.TabIndex = 1; 129 | this.tabPage2.Text = "Новый клиент +"; 130 | this.tabPage2.UseVisualStyleBackColor = true; 131 | // 132 | // label1 133 | // 134 | this.label1.AutoSize = true; 135 | this.label1.Location = new System.Drawing.Point(6, 13); 136 | this.label1.Name = "label1"; 137 | this.label1.Size = new System.Drawing.Size(141, 13); 138 | this.label1.TabIndex = 0; 139 | this.label1.Text = "Недоступно в этой версии"; 140 | // 141 | // clientProviderBindingSource 142 | // 143 | this.clientProviderBindingSource.DataSource = typeof(DvizhSeller.tools.ProductProvider); 144 | // 145 | // ClientsBookForm 146 | // 147 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 148 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 149 | this.ClientSize = new System.Drawing.Size(503, 396); 150 | this.Controls.Add(this.tabControl1); 151 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 152 | this.MaximizeBox = false; 153 | this.MinimizeBox = false; 154 | this.Name = "ClientsBookForm"; 155 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 156 | this.Text = "Справочник клиентов"; 157 | this.Load += new System.EventHandler(this.ClientsBookForm_Load); 158 | this.tabControl1.ResumeLayout(false); 159 | this.tabPage1.ResumeLayout(false); 160 | this.tabPage1.PerformLayout(); 161 | ((System.ComponentModel.ISupportInitialize)(this.clientsGridView)).EndInit(); 162 | this.tabPage2.ResumeLayout(false); 163 | this.tabPage2.PerformLayout(); 164 | ((System.ComponentModel.ISupportInitialize)(this.clientProviderBindingSource)).EndInit(); 165 | this.ResumeLayout(false); 166 | 167 | } 168 | 169 | #endregion 170 | 171 | private System.Windows.Forms.TabControl tabControl1; 172 | private System.Windows.Forms.TabPage tabPage1; 173 | private System.Windows.Forms.Label label2; 174 | private System.Windows.Forms.TextBox searchBox; 175 | private System.Windows.Forms.DataGridView clientsGridView; 176 | private System.Windows.Forms.TabPage tabPage2; 177 | private System.Windows.Forms.Label label1; 178 | private System.Windows.Forms.DataGridViewTextBoxColumn Amount; 179 | private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn1; 180 | private System.Windows.Forms.BindingSource clientProviderBindingSource; 181 | } 182 | } -------------------------------------------------------------------------------- /DiscountsBookForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DvizhSeller 2 | { 3 | partial class DiscountsBookForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DiscountsBookForm)); 33 | this.tabControl1 = new System.Windows.Forms.TabControl(); 34 | this.tabPage1 = new System.Windows.Forms.TabPage(); 35 | this.label2 = new System.Windows.Forms.Label(); 36 | this.searchBox = new System.Windows.Forms.TextBox(); 37 | this.discountsGridView = new System.Windows.Forms.DataGridView(); 38 | this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 39 | this.Amount = new System.Windows.Forms.DataGridViewTextBoxColumn(); 40 | this.disountProviderBindingSource = new System.Windows.Forms.BindingSource(this.components); 41 | this.tabPage2 = new System.Windows.Forms.TabPage(); 42 | this.label1 = new System.Windows.Forms.Label(); 43 | this.tabControl1.SuspendLayout(); 44 | this.tabPage1.SuspendLayout(); 45 | ((System.ComponentModel.ISupportInitialize)(this.discountsGridView)).BeginInit(); 46 | ((System.ComponentModel.ISupportInitialize)(this.disountProviderBindingSource)).BeginInit(); 47 | this.tabPage2.SuspendLayout(); 48 | this.SuspendLayout(); 49 | // 50 | // tabControl1 51 | // 52 | this.tabControl1.Controls.Add(this.tabPage1); 53 | this.tabControl1.Controls.Add(this.tabPage2); 54 | this.tabControl1.Location = new System.Drawing.Point(12, 12); 55 | this.tabControl1.Name = "tabControl1"; 56 | this.tabControl1.SelectedIndex = 0; 57 | this.tabControl1.Size = new System.Drawing.Size(226, 377); 58 | this.tabControl1.TabIndex = 2; 59 | // 60 | // tabPage1 61 | // 62 | this.tabPage1.Controls.Add(this.label2); 63 | this.tabPage1.Controls.Add(this.searchBox); 64 | this.tabPage1.Controls.Add(this.discountsGridView); 65 | this.tabPage1.Location = new System.Drawing.Point(4, 22); 66 | this.tabPage1.Name = "tabPage1"; 67 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 68 | this.tabPage1.Size = new System.Drawing.Size(218, 351); 69 | this.tabPage1.TabIndex = 0; 70 | this.tabPage1.Text = "Скидки"; 71 | this.tabPage1.UseVisualStyleBackColor = true; 72 | // 73 | // label2 74 | // 75 | this.label2.AutoSize = true; 76 | this.label2.Location = new System.Drawing.Point(6, 11); 77 | this.label2.Name = "label2"; 78 | this.label2.Size = new System.Drawing.Size(42, 13); 79 | this.label2.TabIndex = 2; 80 | this.label2.Text = "Поиск:"; 81 | // 82 | // searchBox 83 | // 84 | this.searchBox.Location = new System.Drawing.Point(54, 8); 85 | this.searchBox.Name = "searchBox"; 86 | this.searchBox.Size = new System.Drawing.Size(158, 20); 87 | this.searchBox.TabIndex = 1; 88 | this.searchBox.Text = "Код"; 89 | this.searchBox.Click += new System.EventHandler(this.searchBox_Click); 90 | this.searchBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchBox_KeyDown); 91 | // 92 | // discountsGridView 93 | // 94 | this.discountsGridView.AutoGenerateColumns = false; 95 | this.discountsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 96 | this.discountsGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 97 | this.nameDataGridViewTextBoxColumn, 98 | this.Amount}); 99 | this.discountsGridView.DataSource = this.disountProviderBindingSource; 100 | this.discountsGridView.Location = new System.Drawing.Point(0, 34); 101 | this.discountsGridView.Name = "discountsGridView"; 102 | this.discountsGridView.ReadOnly = true; 103 | this.discountsGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; 104 | this.discountsGridView.Size = new System.Drawing.Size(215, 311); 105 | this.discountsGridView.TabIndex = 0; 106 | // 107 | // nameDataGridViewTextBoxColumn 108 | // 109 | this.nameDataGridViewTextBoxColumn.DataPropertyName = "Code"; 110 | this.nameDataGridViewTextBoxColumn.HeaderText = "Код"; 111 | this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; 112 | this.nameDataGridViewTextBoxColumn.ReadOnly = true; 113 | // 114 | // Amount 115 | // 116 | this.Amount.DataPropertyName = "DiscountVal"; 117 | this.Amount.HeaderText = "Скидка"; 118 | this.Amount.Name = "Amount"; 119 | this.Amount.ReadOnly = true; 120 | this.Amount.Width = 50; 121 | // 122 | // disountProviderBindingSource 123 | // 124 | this.disountProviderBindingSource.DataSource = typeof(DvizhSeller.tools.DisountProvider); 125 | // 126 | // tabPage2 127 | // 128 | this.tabPage2.Controls.Add(this.label1); 129 | this.tabPage2.Location = new System.Drawing.Point(4, 22); 130 | this.tabPage2.Name = "tabPage2"; 131 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3); 132 | this.tabPage2.Size = new System.Drawing.Size(218, 351); 133 | this.tabPage2.TabIndex = 1; 134 | this.tabPage2.Text = "Новая скидка +"; 135 | this.tabPage2.UseVisualStyleBackColor = true; 136 | // 137 | // label1 138 | // 139 | this.label1.AutoSize = true; 140 | this.label1.Location = new System.Drawing.Point(6, 13); 141 | this.label1.Name = "label1"; 142 | this.label1.Size = new System.Drawing.Size(141, 13); 143 | this.label1.TabIndex = 0; 144 | this.label1.Text = "Недоступно в этой версии"; 145 | // 146 | // DiscountsBookForm 147 | // 148 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 149 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 150 | this.ClientSize = new System.Drawing.Size(250, 396); 151 | this.Controls.Add(this.tabControl1); 152 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 153 | this.MaximizeBox = false; 154 | this.MinimizeBox = false; 155 | this.Name = "DiscountsBookForm"; 156 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 157 | this.Text = "Справочник скидок"; 158 | this.Load += new System.EventHandler(this.DiscountsBookForm_Load); 159 | this.tabControl1.ResumeLayout(false); 160 | this.tabPage1.ResumeLayout(false); 161 | this.tabPage1.PerformLayout(); 162 | ((System.ComponentModel.ISupportInitialize)(this.discountsGridView)).EndInit(); 163 | ((System.ComponentModel.ISupportInitialize)(this.disountProviderBindingSource)).EndInit(); 164 | this.tabPage2.ResumeLayout(false); 165 | this.tabPage2.PerformLayout(); 166 | this.ResumeLayout(false); 167 | 168 | } 169 | 170 | #endregion 171 | 172 | private System.Windows.Forms.TabControl tabControl1; 173 | private System.Windows.Forms.TabPage tabPage1; 174 | private System.Windows.Forms.Label label2; 175 | private System.Windows.Forms.TextBox searchBox; 176 | private System.Windows.Forms.DataGridView discountsGridView; 177 | private System.Windows.Forms.TabPage tabPage2; 178 | private System.Windows.Forms.Label label1; 179 | private System.Windows.Forms.BindingSource disountProviderBindingSource; 180 | private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; 181 | private System.Windows.Forms.DataGridViewTextBoxColumn Amount; 182 | } 183 | } -------------------------------------------------------------------------------- /drivers/Atol.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace DvizhSeller.drivers 8 | { 9 | public class Atol : FiscalInterface 10 | { 11 | private string cashierName = "Unknow"; 12 | private int docNumber = 1; 13 | private byte numDepart = 1; 14 | private List statuses; 15 | private byte taxNumber = 1; 16 | bool driverExists = true; 17 | 18 | FprnM1C.IFprnM45 cmd; 19 | 20 | dynamic driver = false; 21 | 22 | public const int DOC_TYPE_SERVICE = 0; //For print texts 23 | public const int DOC_TYPE_REGISTER = 1; //For fiscal registration 24 | public const int DOC_TYPE_ANNULATE = 2; 25 | 26 | public Atol() 27 | { 28 | statuses = new List(); 29 | 30 | try 31 | { 32 | driver = Type.GetTypeFromProgID("AddIn.FPrnM45"); 33 | if (driver != null) 34 | cmd = Activator.CreateInstance(driver); 35 | else 36 | { 37 | driverExists = false; 38 | return; 39 | } 40 | 41 | driverExists = true; 42 | 43 | if (cmd.CheckState != 0) 44 | cmd.CancelCheck(); 45 | 46 | cmd.AttrPrint = 1; 47 | 48 | cmd.DeviceEnabled = true; 49 | cmd.Password = "30"; 50 | 51 | if (cmd.GetStatus() < 0) 52 | MessageBox.Show("Ошибка ККТ: " + cmd.GetStatus().ToString()); 53 | } 54 | catch (Exception e) 55 | { 56 | MessageBox.Show("Не удалось загрузить драйвер Атол."); 57 | driverExists = false; 58 | } 59 | } 60 | 61 | public bool Ready() 62 | { 63 | return driverExists; 64 | } 65 | 66 | public void OpenDocument(byte type) 67 | { 68 | if (!driverExists) 69 | return; 70 | if (type > 2) 71 | type = DOC_TYPE_ANNULATE; 72 | else 73 | type = DOC_TYPE_REGISTER; 74 | 75 | cmd.OperatorName = cashierName; 76 | 77 | cmd.Mode = 1; 78 | cmd.SetMode(); 79 | 80 | cmd.TestMode = Properties.Settings.Default.testMode; 81 | cmd.CheckType = type; 82 | 83 | cmd.OpenCheck(); 84 | 85 | if (cmd.Fiscal) 86 | cmd.BeginFiscDocument(); 87 | else 88 | cmd.BeginDocument(); 89 | } 90 | 91 | public void CloseDocument() 92 | { 93 | if (!driverExists) 94 | return; 95 | 96 | cmd.CloseCheck(); 97 | 98 | if (cmd.Fiscal) 99 | cmd.EndFiscDocument(); 100 | else 101 | cmd.EndDocument(); 102 | } 103 | 104 | public List GetStatuses() 105 | { 106 | return statuses; 107 | } 108 | 109 | public void SetTaxNumber(byte number) 110 | { 111 | taxNumber = number; 112 | } 113 | 114 | public void SetCashierName(string name) 115 | { 116 | cashierName = name; 117 | } 118 | 119 | public void SetNumDepart(byte number) 120 | { 121 | numDepart = number; 122 | } 123 | 124 | public void SetDocNumber(int number) 125 | { 126 | docNumber = number; 127 | } 128 | 129 | public void ScrollPaper() 130 | { 131 | //none 132 | } 133 | 134 | public void PrintString(string text) 135 | { 136 | if (!driverExists) 137 | return; 138 | 139 | cmd.Mode = 1; 140 | cmd.SetMode(); 141 | cmd.Alignment = 1; 142 | cmd.Caption = text; 143 | cmd.PrintString(); 144 | } 145 | 146 | public void RegisterProduct(string name, string barcode, double quantity, double price, int numPos = 1) 147 | { 148 | if (!driverExists) 149 | return; 150 | 151 | if (cmd.GetStatus() < 0) 152 | { 153 | MessageBox.Show("Ошибка ККМ: " + cmd.GetStatus().ToString()); 154 | return; 155 | } 156 | cmd.TaxTypeNumber = Properties.Settings.Default.taxType; 157 | cmd.SummTax(); 158 | 159 | cmd.Name = name; 160 | cmd.Price = price; 161 | cmd.Quantity = quantity; 162 | cmd.Department = numPos; 163 | 164 | cmd.Registration(); 165 | } 166 | 167 | public void AnnulateProduct(string name, double quantity, double price) 168 | { 169 | if (!driverExists) 170 | return; 171 | if (cmd.GetStatus() < 0) { 172 | MessageBox.Show("Ошибка ККМ: " + cmd.GetStatus().ToString()); 173 | return; 174 | } 175 | 176 | cmd.Alignment = 1; 177 | cmd.Caption = "Отмена операции"; 178 | cmd.PrintString(); 179 | 180 | cmd.Name = name; 181 | cmd.Price = price; 182 | cmd.Quantity = quantity; 183 | 184 | cmd.Caption = name + " - отменен"; 185 | cmd.PrintString(); 186 | 187 | cmd.BuyReturn(); 188 | 189 | cmd.Registration(); 190 | } 191 | 192 | public void Storning(string name, double quantity, double price) 193 | { 194 | if (!driverExists) 195 | return; 196 | 197 | if (cmd.GetStatus() < 0) 198 | { 199 | MessageBox.Show("Ошибка ККМ: " + cmd.GetStatus().ToString()); 200 | return; 201 | } 202 | 203 | cmd.Alignment = 1; 204 | cmd.Caption = "Сторнирование"; 205 | cmd.PrintString(); 206 | 207 | cmd.Name = name; 208 | cmd.Price = price; 209 | cmd.Quantity = quantity; 210 | 211 | cmd.Caption = name + " - " + price + "х" + quantity + " = " +quantity*price; 212 | cmd.PrintString(); 213 | 214 | cmd.BuyReturn(); 215 | 216 | cmd.Registration(); 217 | } 218 | 219 | public void RegisterPayment(double sum, byte type = 0) 220 | { 221 | if (!driverExists) 222 | return; 223 | 224 | cmd.Mode = 1; 225 | cmd.SetMode(); 226 | cmd.TypeClose = type; 227 | cmd.Summ = sum; 228 | cmd.Payment(); 229 | } 230 | 231 | public void BotIndent() 232 | { 233 | cmd.Caption = ""; 234 | cmd.PrintString(); 235 | cmd.PrintString(); 236 | cmd.Caption = "_________________________________"; 237 | cmd.PrintString(); 238 | cmd.Caption = " (подпись кассира)"; 239 | cmd.PrintString(); 240 | cmd.Caption = ""; 241 | cmd.PrintString(); 242 | cmd.PrintString(); 243 | cmd.Caption = "=================================="; 244 | cmd.PrintString(); 245 | cmd.Caption = " (подпись клиента)"; 246 | cmd.PrintString(); 247 | } 248 | 249 | public void PrintTotal() 250 | { 251 | if (!driverExists) 252 | return; 253 | 254 | cmd.CashIncome(); 255 | } 256 | 257 | public void RegisterDiscount(byte type, string nameDiscount, int sum) 258 | { 259 | cmd.DiscountType = type; 260 | cmd.DiscountValue = sum; 261 | } 262 | 263 | public void PrintServiceData() 264 | { 265 | if (!driverExists) 266 | return; 267 | 268 | cmd.Alignment = 1; 269 | cmd.Caption = "Тестирование печати."; 270 | cmd.PrintString(); 271 | 272 | cmd.Caption = "Все ОК."; 273 | cmd.PrintString(); 274 | 275 | cmd.Caption = "Номер чека: " + cmd.CheckNumber.ToString(); 276 | cmd.PrintString(); 277 | 278 | cmd.Caption = cmd.DeviceSettings; 279 | cmd.PrintString(); 280 | 281 | if (cmd.Fiscal) 282 | cmd.Caption = "Фискальный"; 283 | else 284 | cmd.Caption = "Нефискальный"; 285 | cmd.PrintString(); 286 | 287 | cmd.Caption = "ИНН" + cmd.INN; 288 | cmd.PrintString(); 289 | } 290 | 291 | public void OpenSession() 292 | { 293 | if (!driverExists) 294 | return; 295 | 296 | if (cmd.GetStatus() < 0) 297 | return; 298 | 299 | cmd.Mode = 1; 300 | cmd.SetMode(); 301 | cmd.OpenSession(); 302 | cmd.Beep(); 303 | } 304 | 305 | public void CloseSession() 306 | { 307 | if (!driverExists) 308 | return; 309 | 310 | if (cmd.CheckState != 0) 311 | cmd.CancelCheck(); 312 | 313 | if (cmd.GetStatus() < 0) 314 | return; 315 | 316 | cmd.Mode = 3; 317 | cmd.SetMode(); 318 | cmd.ReportType = 1; 319 | cmd.Report(); 320 | cmd.Beep(); 321 | } 322 | 323 | public bool IsSessionOpen() 324 | { 325 | if(cmd.SessionExceedLimit) 326 | { 327 | MessageBox.Show("Смена превысила 24 часа, нужно перезапустить ее."); 328 | } 329 | 330 | if (cmd.GetStatus() < 0) 331 | return false; 332 | 333 | if (!driverExists) 334 | return false; 335 | 336 | cmd.Mode = 1; 337 | cmd.SetMode(); 338 | 339 | bool opened = cmd.SessionOpened; 340 | 341 | return opened; 342 | } 343 | 344 | ~Atol() 345 | { 346 | cmd.DeviceEnabled = false; 347 | } 348 | } 349 | } 350 | --------------------------------------------------------------------------------