Beispiel #1
0
        public WaitForm(DBProvider db, OperationType opType)
        {
            this.OpType = opType;
            this.db = db;

            InitializeComponent();

            this.Text += " "+opType.ToString();
        }
Beispiel #2
0
        public FrmVKRecalculation(string condition, DBProvider db)
        {
            InitializeComponent();

            this.txtCoef.Text = Properties.Settings.Default.PriceCoef.ToString();

            this.Condition = condition;
            this.CodesSelector = string.Format("select CODE from {0} where {1}", DBProvider.TableNames[0], Condition.Replace("A.", string.Empty));
            this.db = db;
        }
Beispiel #3
0
        public EditSold(DBProvider db, string tableName, string code, bool exh)
        {
            InitializeComponent();

            this.db = db;
            this.Exhibition = exh;

            if (!Exhibition)
                txtExhibition.Enabled = false;
            else
            {
                txtSellDate.Enabled = false;
                txtSellPrice.Enabled = false;
            }

            if (code == null)
            {
                MessageBox.Show(this, "Code is missing!", "Edit sold", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string sExh = string.Empty;
                if (Exhibition)
                    sExh = ", EXHIBITIONNAME";
                else
                    sExh = ", A.SELLDATE, A.SELLPRICE";

                var ds = db.ExecuteQuery(string.Format("select B.CODE, B.ITEMNAME, B.COUNTRY, B.SUPPLIER, B.LENGTH, B.WIDTH, B.VK_NETTO, B.DATE {3} from {0} A join {1} B on A.CODE = B.CODE where A.code = {2}", tableName, DBProvider.TableNames[(int)TABS.MAIN], code, sExh));
                if (ds != null && ds.Tables.Count > 0)
                {
                    var vals = ds.Tables[0].Rows[0].ItemArray;
                    txtCode.Text = vals[0].ToString();
                    txtName.Text = vals[1].ToString();
                    txtCountry.Text = vals[2].ToString();
                    txtSupplier.Text = vals[3].ToString();
                    txtLegnth.Text = vals[4].ToString();
                    txtWidth.Text = vals[5].ToString();
                    txtItemPrice.Text = vals[6].ToString();
                    txtDate.Text = vals[7].ToString();
                    if (Exhibition)
                        txtExhibition.Text = vals[8].ToString();
                    else
                    {
                        txtSellDate.Text = vals[8].ToString();
                        txtSellPrice.Text = vals[9].ToString();
                    }
                }
            }
        }
Beispiel #4
0
        public InventoryResult(DBProvider db, List<string> missingMain, List<string> missingInv)
        {
            InitializeComponent();

            var table = new DataTable("inventory");
            table.Columns.Add("Code");
            missingMain.ForEach(s => table.Rows.Add(s));
            gridMissingMain.DataSource = table;

            var table2 = db.ExecuteQuery(DBProvider.TableNames[0], string.Format(" where code in ({0})", string.Join(",", missingInv.ToArray())), " order by code desc ").Tables[0];
            gridMissingInv.DataSource = table2;

            lblMissingMain.Text = lblMissingMain.Text.Replace("XXX", table.Rows.Count.ToString());
            lblMissingInv.Text = lblMissingInv.Text.Replace("XXX", table2.Rows.Count.ToString());
        }
Beispiel #5
0
        public AddEditMain(DBProvider db, string tableName, string code, EditMode mode)
        {
            InitializeComponent();

            this.mode = mode;
            this.db = db;

            if (code == null)
            {
                txtCode.Text = (db.LoadMaxCode(false) + 1).ToString();
            }
            else
            {
                var ds = db.ExecuteQuery(tableName, " where code = " + code, "");
                if (ds != null && ds.Tables.Count > 0)
                {
                    var vals = ds.Tables[0].Rows[0].ItemArray;

                    txtCode.Text = vals[0].ToString();
                    txtName.Text = vals[1].ToString();
                    txtCountry.Text = vals[2].ToString();
                    txtSupplier.Text = vals[3].ToString();
                    txtSupplierNr.Text = vals[4].ToString();
                    txtLength.Text = vals[5].ToString();
                    txtWidth.Text = vals[6].ToString();
                    txtEKNetto.Text = vals[7].ToString();
                    txtVKNetto.Text = vals[8].ToString();
                    txtQuantity.Text = vals[9].ToString();
                    txtQMPrice.Text = vals[10].ToString();
                    txtDate.Text = vals[11].ToString();
                    txtMVDate.Text = vals[12].ToString();
                    txtInvoice.Text = vals[13].ToString();
                    txtColor.Text = vals[14].ToString();
                    txtMaterial.Text = vals[15].ToString();
                    txtComment.Text = vals[16].ToString();
                    txtInfo.Text = vals[17].ToString();
                    txtEuroStuck.Text = vals[18].ToString();
                    txtPaid.Text = vals[19].ToString();
                }
            }
        }
Beispiel #6
0
        public MainForm()
        {
            InitializeComponent();

            db = new DBProvider(Properties.Settings.Default.DbName);

            Visible = true;

            try
            {
                // inicializacia contextoveho menu pre sold
                contextSold = new ContextMenuStrip();
                var r1 = new ToolStripMenuItem("Only local");
                r1.Click += new EventHandler(SoldLocal);
                contextSold.Items.Add(r1);
                var r2 = new ToolStripMenuItem("Only on web");
                r2.Click += new EventHandler(SoldWeb);
                contextSold.Items.Add(r2);
                contextSold.Items.Add(new ToolStripSeparator());
                var r3 = new ToolStripMenuItem("Local and web");
                r3.Click += new EventHandler(SoldComplet);
                contextSold.Items.Add(r3);

                if (Properties.Settings.Default.AutoBackup && MessageBox.Show(this, "Do you want to backup database before any changes?", "Database backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (!Directory.Exists(Properties.Settings.Default.BackupDirectory))
                        Directory.CreateDirectory(Properties.Settings.Default.BackupDirectory);

                    string destFile = Properties.Settings.Default.BackupDirectory + "\\backup_" + DateTime.Now.ToShortDateString() + "_" + DateTime.Now.Ticks + ".db";
                    File.Copy(Properties.Settings.Default.DbName, destFile);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error while making backup: "+ex.ToString(), "Backup error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshItems();
            ReadQueries();
        }
Beispiel #7
0
        private string CreateDBSoldTXT()
        {
            DBProvider dbp = new DBProvider(Properties.Settings.Default.PtcommDir + @"\arena.db");
            var data = dbp.ExecuteQuery(DBProvider.TableNames[1], " where VALID = 1 ", "");
            if (data.Tables != null && data.Tables.Count == 1)
            {
                var res = new List<string>();
                foreach (DataRow r in data.Tables[0].Rows)
                {
                    res.Add(r[0].ToString());
                    res.Add(r[1].ToString());
                    res.Add(r[2].ToString());
                }

                var ret = Properties.Settings.Default.PtcommDir + @"\DBSOLD.TXT";
                File.WriteAllLines(ret, res.ToArray());

                return ret;
            }

            return null;
        }
Beispiel #8
0
        public static void InsertMultiple(BindingList<DataItem> itemsDs, DBProvider db, bool _5series)
        {
            if (itemsDs == null)
                return;

            DataSource = itemsDs;
            dbProvider = db;

            Progress p = new Progress(0, 100, "Batch inserting..", "Loading max code", Inserting, null, _5series, true, true);
            p.StartWorker();
        }