Ejemplo n.º 1
0
        private void LoadFile()
        {
            Cursor.Current = Cursors.WaitCursor;

            string invfile = "invfiles/" + mclsBranchDetails.BranchCode + ".inv"; //mclsInvLog.LogFile;

            if (!System.IO.File.Exists(invfile))
            {
                Data.BranchDetails clsBranchDetails = mclsBranchDetails;
                mclsInvLog = new InvLog();
                LoadOptions();
                mclsBranchDetails = clsBranchDetails;
                cmdBranchSelect.Text = mclsBranchDetails.BranchCode;
            }
            else if (System.IO.File.Exists(invfile))
            {
                mdtItems = new System.Data.DataTable("tblInvItems");
                mdtItems.Columns.Add("BarCode");
                mdtItems.Columns.Add("Quantity");
                mdtItems.Columns.Add("Unit");
                mdtItems.Columns.Add("Description");

                using (var reader = new StreamReader(invfile))
                {
                    string line; int iCtr = 0; 
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (iCtr >= 4)
                        {
                            string[] item = line.Split('|');
                            mdtItems.Rows.Add(item[0], item[1], item[2], item[3]);
                        }
                        iCtr++;
                    }
                }

                dgvItems.MultiSelect = false;
                dgvItems.AutoGenerateColumns = true;
                dgvItems.AutoSize = true;
                dgvItems.ScrollBars = ScrollBars.Vertical;
                dgvItems.DataSource = mdtItems.TableName;
                dgvItems.DataSource = mdtItems;

                dgvItems.Columns["BarCode"].Visible = true;
                dgvItems.Columns["Quantity"].Visible = true;
                dgvItems.Columns["Unit"].Visible = true;
                dgvItems.Columns["Description"].Visible = true;

                dgvItems.Columns["BarCode"].HeaderText = "BarCode";
                dgvItems.Columns["Quantity"].HeaderText = "Quantity";
                dgvItems.Columns["Unit"].HeaderText = "Unit";
                dgvItems.Columns["Description"].HeaderText = "Description";

                dgvItems.Columns["BarCode"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
                dgvItems.Columns["Quantity"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Unit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
                dgvItems.Columns["Description"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;

                dgvItems.Columns["BarCode"].Width = 230;
                dgvItems.Columns["Quantity"].Width = 100;
                dgvItems.Columns["Unit"].Width = 100;
                dgvItems.Columns["Description"].Width = dgvItems.Width - 450;

                dgvItems.Rows[dgvItems.Rows.Count-1].Selected = true;
                dgvItems.FirstDisplayedScrollingRowIndex = dgvItems.Rows.Count - 1;

                mclsInvLog.LogFile = invfile;
            }
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 2
0
        private void LoadFile()
        {
            Cursor.Current = Cursors.WaitCursor;

            string invfile = "invfiles/" + mclsBranchDetails.BranchCode + ".inv"; //mclsInvLog.LogFile;

            if (!System.IO.File.Exists(invfile))
            {
                Data.BranchDetails clsBranchDetails = mclsBranchDetails;
                mclsInvLog = new InvLog();
                LoadOptions();
                mclsBranchDetails    = clsBranchDetails;
                cmdBranchSelect.Text = mclsBranchDetails.BranchCode;
            }
            else if (System.IO.File.Exists(invfile))
            {
                mdtItems = new System.Data.DataTable("tblInvItems");
                mdtItems.Columns.Add("BarCode");
                mdtItems.Columns.Add("Quantity");
                mdtItems.Columns.Add("Unit");
                mdtItems.Columns.Add("Description");

                using (var reader = new StreamReader(invfile))
                {
                    string line; int iCtr = 0;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (iCtr >= 4)
                        {
                            string[] item = line.Split('|');
                            mdtItems.Rows.Add(item[0], item[1], item[2], item[3]);
                        }
                        iCtr++;
                    }
                }

                dgvItems.MultiSelect         = false;
                dgvItems.AutoGenerateColumns = true;
                dgvItems.AutoSize            = true;
                dgvItems.ScrollBars          = ScrollBars.Vertical;
                dgvItems.DataSource          = mdtItems.TableName;
                dgvItems.DataSource          = mdtItems;

                dgvItems.Columns["BarCode"].Visible     = true;
                dgvItems.Columns["Quantity"].Visible    = true;
                dgvItems.Columns["Unit"].Visible        = true;
                dgvItems.Columns["Description"].Visible = true;

                dgvItems.Columns["BarCode"].HeaderText     = "BarCode";
                dgvItems.Columns["Quantity"].HeaderText    = "Quantity";
                dgvItems.Columns["Unit"].HeaderText        = "Unit";
                dgvItems.Columns["Description"].HeaderText = "Description";

                dgvItems.Columns["BarCode"].DefaultCellStyle.Alignment     = DataGridViewContentAlignment.MiddleLeft;
                dgvItems.Columns["Quantity"].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Unit"].DefaultCellStyle.Alignment        = DataGridViewContentAlignment.MiddleLeft;
                dgvItems.Columns["Description"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;

                dgvItems.Columns["BarCode"].Width     = 230;
                dgvItems.Columns["Quantity"].Width    = 100;
                dgvItems.Columns["Unit"].Width        = 100;
                dgvItems.Columns["Description"].Width = dgvItems.Width - 450;

                dgvItems.Rows[dgvItems.Rows.Count - 1].Selected = true;
                dgvItems.FirstDisplayedScrollingRowIndex        = dgvItems.Rows.Count - 1;

                mclsInvLog.LogFile = invfile;
            }
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 3
0
        private void Main_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.F2:   // clear inventory file
                    if (mclsBranchDetails.BranchID == 0)
                    {
                        MessageBox.Show("Please select the branch to clear the inventory file.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdBranchSelect.Focus();
                        return;
                    }
                    if (MessageBox.Show("Are you sure you want to clear the inventory file of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    {
                        Data.BranchDetails clsBranchDetails = mclsBranchDetails;
                        if (!Directory.Exists("invfiles/backups/")) Directory.CreateDirectory("invfiles/backups/");
                        System.IO.File.Copy(mclsInvLog.LogFile, "invfiles/backups/" + mclsBranchDetails.BranchCode + "_" + DateTime.Now.ToString("yyyyddMMhhmmss") + ".inv");
                        System.IO.File.Delete(mclsInvLog.LogFile);
                        mclsInvLog = new InvLog();
                        LoadOptions();
                        LoadFile();
                        mclsBranchDetails = clsBranchDetails;
                        cmdBranchSelect.Text = mclsBranchDetails.BranchCode;
                    }
                    break;
                case Keys.F3:
                    LogInWnd login = new LogInWnd();

                    login.AccessType = AccessTypes.ZeroOutBranchInventory;
                    login.Header = "Zero Out Inventory of Branch: access validation";
                    login.ShowDialog(this);
                    DialogResult loginresult = login.Result;
                    login.Close();
                    login.Dispose();

                    if (loginresult == DialogResult.OK)
                    {
                        grpSaveToDB.Visible = false;
                        if (mclsBranchDetails.BranchID == 0)
                        {
                            MessageBox.Show("Please select the branch to zero out the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            cmdBranchSelect.Focus();
                            return;
                        }
                        if (MessageBox.Show("Are you sure you want to ZERO out the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                        {
                                grpSaveToDB.Visible = true;
                                Cursor.Current = Cursors.WaitCursor;

                                this.bgwZeroOutInv.RunWorkerAsync();

                                // Wait for the BackgroundWorker to finish the download.
                                while (this.bgwZeroOutInv.IsBusy)
                                {
                                    //prgBar.Increment(1);
                                    // Keep UI messages moving, so the form remains 
                                    // responsive during the asynchronous operation.
                                    Application.DoEvents();
                                }
                            }
                        }
                        break;
                    
                case Keys.F4:
                    grpSaveToDB.Visible = false;
                    if (mclsBranchDetails.BranchID == 0)
                    {
                        MessageBox.Show("Please select the branch to upload the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdBranchSelect.Focus();
                        return;
                    }
                    if (mdtItems == null || mdtItems.Rows.Count == 0)
                    {
                        MessageBox.Show("No rows to upload, please make sure the inventory file is loaded.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (MessageBox.Show("Are you sure you want to UPLOAD the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    {
                        grpSaveToDB.Visible = true;
                        Cursor.Current = Cursors.WaitCursor;

                        this.bgwSavetoDB.RunWorkerAsync();

                        // Wait for the BackgroundWorker to finish the download.
                        while (this.bgwSavetoDB.IsBusy)
                        {
                            //prgBar.Increment(1);
                            // Keep UI messages moving, so the form remains 
                            // responsive during the asynchronous operation.
                            Application.DoEvents();
                        }
                    }
                    break;
                case Keys.F5:
                    isLoadInReverse = false;
                    grpSaveToDB.Visible = false;
                    if (mclsBranchDetails.BranchID == 0)
                    {
                        MessageBox.Show("Please select the branch to zero out the NEGATIVE inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdBranchSelect.Focus();
                        return;
                    }
                    if (MessageBox.Show("Are you sure you want to ZERO out the NEGATIVE  inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    {
                        grpSaveToDB.Visible = true;
                        Cursor.Current = Cursors.WaitCursor;

                        this.bgwZeroOutInvNeg.RunWorkerAsync();

                        // Wait for the BackgroundWorker to finish the download.
                        while (this.bgwZeroOutInvNeg.IsBusy)
                        {
                            //prgBar.Increment(1);
                            // Keep UI messages moving, so the form remains 
                            // responsive during the asynchronous operation.
                            Application.DoEvents();
                        }
                    }
                    break;

                case Keys.F7:
                    isLoadInReverse = true;

                    grpSaveToDB.Visible = false;
                    if (mclsBranchDetails.BranchID == 0)
                    {
                        MessageBox.Show("Please select the branch to upload the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdBranchSelect.Focus();
                        return;
                    }
                    if (mdtItems == null || mdtItems.Rows.Count == 0)
                    {
                        MessageBox.Show("No rows to upload, please make sure the inventory file is loaded.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (MessageBox.Show("Are you sure you want to UPLOAD the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    {
                        grpSaveToDB.Visible = true;
                        Cursor.Current = Cursors.WaitCursor;

                        this.bgwSavetoDB.RunWorkerAsync();

                        // Wait for the BackgroundWorker to finish the download.
                        while (this.bgwSavetoDB.IsBusy)
                        {
                            //prgBar.Increment(1);
                            // Keep UI messages moving, so the form remains 
                            // responsive during the asynchronous operation.
                            Application.DoEvents();
                        }
                    }
                    break;
                case Keys.Escape:
                    if (MessageBox.Show("Are you sure you want to exit?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                    {
                        Application.Exit();
                    }
                    break;
            }
        }
Ejemplo n.º 4
0
        private void Main_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.F2:       // clear inventory file
                if (mclsBranchDetails.BranchID == 0)
                {
                    MessageBox.Show("Please select the branch to clear the inventory file.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdBranchSelect.Focus();
                    return;
                }
                if (MessageBox.Show("Are you sure you want to clear the inventory file of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    Data.BranchDetails clsBranchDetails = mclsBranchDetails;
                    if (!Directory.Exists("invfiles/backups/"))
                    {
                        Directory.CreateDirectory("invfiles/backups/");
                    }
                    System.IO.File.Copy(mclsInvLog.LogFile, "invfiles/backups/" + mclsBranchDetails.BranchCode + "_" + DateTime.Now.ToString("yyyyddMMhhmmss") + ".inv");
                    System.IO.File.Delete(mclsInvLog.LogFile);
                    mclsInvLog = new InvLog();
                    LoadOptions();
                    LoadFile();
                    mclsBranchDetails    = clsBranchDetails;
                    cmdBranchSelect.Text = mclsBranchDetails.BranchCode;
                }
                break;

            case Keys.F3:
                LogInWnd login = new LogInWnd();

                login.AccessType = AccessTypes.ZeroOutBranchInventory;
                login.Header     = "Zero Out Inventory of Branch: access validation";
                login.ShowDialog(this);
                DialogResult loginresult = login.Result;
                login.Close();
                login.Dispose();

                if (loginresult == DialogResult.OK)
                {
                    grpSaveToDB.Visible = false;
                    if (mclsBranchDetails.BranchID == 0)
                    {
                        MessageBox.Show("Please select the branch to zero out the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdBranchSelect.Focus();
                        return;
                    }
                    if (MessageBox.Show("Are you sure you want to ZERO out the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    {
                        grpSaveToDB.Visible = true;
                        Cursor.Current      = Cursors.WaitCursor;

                        this.bgwZeroOutInv.RunWorkerAsync();

                        // Wait for the BackgroundWorker to finish the download.
                        while (this.bgwZeroOutInv.IsBusy)
                        {
                            //prgBar.Increment(1);
                            // Keep UI messages moving, so the form remains
                            // responsive during the asynchronous operation.
                            Application.DoEvents();
                        }
                    }
                }
                break;

            case Keys.F4:
                grpSaveToDB.Visible = false;
                if (mclsBranchDetails.BranchID == 0)
                {
                    MessageBox.Show("Please select the branch to upload the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdBranchSelect.Focus();
                    return;
                }
                if (mdtItems == null || mdtItems.Rows.Count == 0)
                {
                    MessageBox.Show("No rows to upload, please make sure the inventory file is loaded.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (MessageBox.Show("Are you sure you want to UPLOAD the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    grpSaveToDB.Visible = true;
                    Cursor.Current      = Cursors.WaitCursor;

                    this.bgwSavetoDB.RunWorkerAsync();

                    // Wait for the BackgroundWorker to finish the download.
                    while (this.bgwSavetoDB.IsBusy)
                    {
                        //prgBar.Increment(1);
                        // Keep UI messages moving, so the form remains
                        // responsive during the asynchronous operation.
                        Application.DoEvents();
                    }
                }
                break;

            case Keys.F5:
                isLoadInReverse     = false;
                grpSaveToDB.Visible = false;
                if (mclsBranchDetails.BranchID == 0)
                {
                    MessageBox.Show("Please select the branch to zero out the NEGATIVE inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdBranchSelect.Focus();
                    return;
                }
                if (MessageBox.Show("Are you sure you want to ZERO out the NEGATIVE  inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    grpSaveToDB.Visible = true;
                    Cursor.Current      = Cursors.WaitCursor;

                    this.bgwZeroOutInvNeg.RunWorkerAsync();

                    // Wait for the BackgroundWorker to finish the download.
                    while (this.bgwZeroOutInvNeg.IsBusy)
                    {
                        //prgBar.Increment(1);
                        // Keep UI messages moving, so the form remains
                        // responsive during the asynchronous operation.
                        Application.DoEvents();
                    }
                }
                break;

            case Keys.F7:
                isLoadInReverse = true;

                grpSaveToDB.Visible = false;
                if (mclsBranchDetails.BranchID == 0)
                {
                    MessageBox.Show("Please select the branch to upload the inventory.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdBranchSelect.Focus();
                    return;
                }
                if (mdtItems == null || mdtItems.Rows.Count == 0)
                {
                    MessageBox.Show("No rows to upload, please make sure the inventory file is loaded.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (MessageBox.Show("Are you sure you want to UPLOAD the inventory of branch " + mclsBranchDetails.BranchCode + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    grpSaveToDB.Visible = true;
                    Cursor.Current      = Cursors.WaitCursor;

                    this.bgwSavetoDB.RunWorkerAsync();

                    // Wait for the BackgroundWorker to finish the download.
                    while (this.bgwSavetoDB.IsBusy)
                    {
                        //prgBar.Increment(1);
                        // Keep UI messages moving, so the form remains
                        // responsive during the asynchronous operation.
                        Application.DoEvents();
                    }
                }
                break;

            case Keys.Escape:
                if (MessageBox.Show("Are you sure you want to exit?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Application.Exit();
                }
                break;
            }
        }