Ejemplo n.º 1
0
 private void BtnBackUpDataBase_Click(object sender, EventArgs e)
 {
     saveFileDialog1.FileName = "PrepAndPaintDataBase_" + DateTime.Now.Date.ToString("MM-dd-yyyy");
     saveFileDialog1.Filter   = "PrepAndPaint databases (*.db)|*.db";
     saveFileDialog1.ShowDialog();
     PrepAndPaintDB.BackUpDataBase(saveFileDialog1.FileName);
 }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (IsValidate())
     {
         AdminsModel newAdmin = new AdminsModel()
         {
             Name     = txtAdminName.Text,
             Password = txtAdminPassWord.Text
         };
         List <AdminsModel> admins = PrepAndPaintDB.GetAdmins();
         foreach (var name in admins)
         {
             if (name.Name == newAdmin.Name)
             {
                 MessageBox.Show($"Name: {newAdmin.Name} already exist", "Exist Already!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtAdminName.Focus();
                 return;
             }
         }
         PrepAndPaintDB.AddAdmin(newAdmin);
         txtAdminName.Clear();
         txtAdminPassWord.Clear();
         PopulateDataGrid();
     }
 }
Ejemplo n.º 3
0
        private void DeleteEntry()
        {
            if (jobInfoDataGrid.SelectedRows.Count > 0)
            {
                int    selectedRowIndex = jobInfoDataGrid.SelectedCells[0].RowIndex;
                int    Id        = (int)jobInfoDataGrid.Rows[selectedRowIndex].Cells[0].Value;
                string jobNumber = jobInfoDataGrid.Rows[selectedRowIndex].Cells[2].Value.ToString();
                string item      = jobInfoDataGrid.Rows[selectedRowIndex].Cells[3].Value.ToString();
                if (MessageBox.Show($"Are you sure you want to delete line Item {item} for Job# {jobNumber}", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    PrepAndPaintModel deleteId = new PrepAndPaintModel()
                    {
                        Id = Id
                    };
                    PrepAndPaintDB.Delete(deleteId);

                    GetInfo();
                    //if (selectedRowIndex > 0)
                    //{
                    //    jobInfoDataGrid.Rows[selectedRowIndex - 1].Cells[1].Selected = true;
                    //}
                }
            }
            else
            {
                MessageBox.Show("Sorry you need to select an entry to delete!", "Error", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 4
0
 private void btnSearchAnyYear_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtSearch.Text))
     {
         MessageBox.Show("Enter somethingin the search!", "Noting To Search!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (rdoItem.Checked)
     {
         dataGridView.DataSource = PrepAndPaintDB.SearchItemAnyYear(txtSearch.Text);
         if (dataGridView.Rows.Count <= 0)
         {
             MessageBox.Show($"Nothing found with name {txtSearch.Text}", "Nothing found!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             SetDataGridView();
         }
     }
     else if (rdoJobNumber.Checked)
     {
         dataGridView.DataSource = PrepAndPaintDB.SearchJobsByAnyYear(txtSearch.Text);
         if (dataGridView.Rows.Count <= 0)
         {
             MessageBox.Show($"Nothing found for Job# {txtSearch.Text}", "Nothing found!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             SetDataGridView();
         }
     }
 }
Ejemplo n.º 5
0
 private void DeleteEntry()
 {
     if (dataGridView.SelectedRows.Count > 0)
     {
         int    selectedRowIndex = dataGridView.SelectedCells[0].RowIndex;
         int    Id  = (int)dataGridView.Rows[selectedRowIndex].Cells[0].Value;
         string job = dataGridView.Rows[selectedRowIndex].Cells[1].Value.ToString();
         if (MessageBox.Show($"Are you sure you want to delete job #{job}?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             PrepAndPaintModel deleteId = new PrepAndPaintModel()
             {
                 Id = Id
             };
             PrepAndPaintDB.Delete(deleteId);
             GetInfo();
             if (selectedRowIndex > 0)
             {
                 dataGridView.Rows[selectedRowIndex - 1].Cells[1].Selected = true;
             }
         }
     }
     else
     {
         MessageBox.Show("Sorry you need to select an entry to delete!", "Error", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 6
0
 private void GetInfo()
 {
     dataGridView1.DataSource              = PrepAndPaintDB.GetSuperVisorInfo();
     dataGridView1.Columns[0].Visible      = false;
     dataGridView1.AutoSizeColumnsMode     = DataGridViewAutoSizeColumnsMode.DisplayedCells;
     dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
 }
Ejemplo n.º 7
0
        private void GetItemInfo()
        {
            List <ItemsModel> list = PrepAndPaintDB.GetItemsList();

            foreach (var item in list)
            {
                itemsListBox.Items.Add(item.ItemName);
            }
        }
Ejemplo n.º 8
0
        private void PassWord_Load(object sender, EventArgs e)
        {
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            if (adminList.Count == 0)
            {
                MessageBox.Show("Currently there are no admins. Please create an admin account to protect your data", "No Admins!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                AdminPage adminPage = new AdminPage();
                adminPage.ShowDialog();
            }
        }
Ejemplo n.º 9
0
        private void MarkJobCompleted(bool completed)
        {
            JobsModel editJob = new JobsModel()
            {
                Id        = job.Id,
                JobNumber = job.JobNumber,
                Customer  = job.Customer,
                Model     = job.Model,
                Completed = completed
            };

            PrepAndPaintDB.EditJob(editJob);
        }
Ejemplo n.º 10
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (IsValidate())
            {
                if (edit)
                {
                    CheckStartDate();
                    CheckPaintDate();
                    PrepAndPaintModel edited = new PrepAndPaintModel()
                    {
                        Id          = editJob.Id,
                        StartDate   = startDate,
                        JobNumber   = txtJobNumber.Text,
                        Prepper     = txtPrepper.Text,
                        PaintDate   = paintDate,
                        Painter     = txtPainter.Text,
                        BodyOrDoors = cmboBodyDoors.Text,
                        Booth       = cmboBooth.Text,
                        Colour      = cmboColour.Text,
                        NewProcess  = checkNewProcess.Checked,
                        WashBay     = checkWashBay.Checked,
                        Comments    = txtComments.Text
                    };
                    PrepAndPaintDB.EditnewJob(edited);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    CheckStartDate();
                    CheckPaintDate();
                    PrepAndPaintModel newJob = new PrepAndPaintModel()
                    {
                        StartDate   = startDate,
                        JobNumber   = txtJobNumber.Text,
                        Prepper     = txtPrepper.Text,
                        PaintDate   = paintDate,
                        Painter     = txtPainter.Text,
                        BodyOrDoors = cmboBodyDoors.Text,
                        Booth       = cmboBooth.Text,
                        Colour      = cmboColour.Text,
                        NewProcess  = checkNewProcess.Checked,
                        WashBay     = checkWashBay.Checked,
                        Comments    = txtComments.Text
                    };

                    CheckIfExist(newJob);
                }
            }
        }
Ejemplo n.º 11
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            if (adminList.Count == 0)
            {
                MessageBox.Show("Currently there are no admins. Please create an admin account to protect your data", "No Admins!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Close();
            }
        }
Ejemplo n.º 12
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            JobsModel edited = new JobsModel()
            {
                Id        = job.Id,
                JobNumber = job.JobNumber,
                Customer  = txtCustomer.Text,
                Model     = txtModel.Text
            };

            PrepAndPaintDB.EditJob(edited);
            jobId        = edited.Id;
            DialogResult = DialogResult.OK;
            Close();
        }
Ejemplo n.º 13
0
        private void BtnRestoreDataBase_Click(object sender, EventArgs e)
        {
            PassWord     passWord = new PassWord();
            DialogResult result   = passWord.ShowDialog();

            if (result == DialogResult.OK)
            {
                openFileDialog1.FileName = "";
                openFileDialog1.Filter   = "PrepAndPaint databases (*.db)|*.db";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    PrepAndPaintDB.RestoreDataBase(openFileDialog1.FileName);
                    GetInfo();
                }
            }
        }
Ejemplo n.º 14
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtNotes.Text))
     {
         SupervisorNotesModel editSupervisorNotes = new SupervisorNotesModel()
         {
             Date     = dateTimePicker1.Value.Date,
             Comments = txtNotes.Text
         };
         PrepAndPaintDB.SaveSuperVisorNotes(editSupervisorNotes);
         this.DialogResult = DialogResult.OK;
         Close();
     }
     else
     {
         MessageBox.Show("You didn't enter anything", "Error");
     }
 }
Ejemplo n.º 15
0
        private void CheckIfExist(PrepAndPaintModel newJob)
        {
            List <PrepAndPaintModel> prepAndPaintModels = PrepAndPaintDB.GetNewData();

            foreach (var item in prepAndPaintModels)
            {
                if (item.JobNumber == newJob.JobNumber && item.BodyOrDoors == newJob.BodyOrDoors)
                {
                    MessageBox.Show($"Item: {newJob.BodyOrDoors} already exist for Job# {newJob.JobNumber} in the database!",
                                    "Entry Exist!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            PrepAndPaintDB.AddnewJob(newJob);
            jobId        = newJob.Id;
            DialogResult = DialogResult.OK;
            Close();
        }
Ejemplo n.º 16
0
 private void DeleteNote()
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         int selectedRowIndex = dataGridView1.SelectedCells[0].RowIndex;
         int Id = (int)dataGridView1.Rows[selectedRowIndex].Cells[0].Value;
         if (MessageBox.Show("Are you sure you wanted to delete this entry?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             SupervisorNotesModel deleteId = new SupervisorNotesModel()
             {
                 Id = Id
             };
             PrepAndPaintDB.DeleteSuperVisorNote(deleteId);
         }
         GetInfo();
     }
     else
     {
         MessageBox.Show("Sorry you need to select an entry to delete!", "Error", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 17
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int    selectedRowIndex = itemDataGridView.SelectedCells[0].RowIndex;
         int    id       = (int)itemDataGridView.Rows[selectedRowIndex].Cells[0].Value;
         string itemname = itemDataGridView.Rows[selectedRowIndex].Cells[1].Value.ToString();
         if (MessageBox.Show($"Are you sure you wanted to delete Item: {itemname}?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ItemsModel deleteId = new ItemsModel()
             {
                 Id = id
             };
             PrepAndPaintDB.DeleteItem(deleteId);
             PopulateListView();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Nothing selected to delete!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 18
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            string             login     = txtLogin.Text;
            string             password  = txtPassWord.Text;
            List <AdminsModel> adminList = PrepAndPaintDB.GetAdmins();

            foreach (var name in adminList)
            {
                if (login == name.Name && password == name.Password)
                {
                    adminLogin        = true;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Sorry login or password wrong! Please try again", "Incorrect PassWord!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPassWord.Clear();
                    txtPassWord.Focus();
                    return;
                }
            }
        }
Ejemplo n.º 19
0
 private void BtnAddColour_Click(object sender, EventArgs e)
 {
     if (IsValidate())
     {
         string          colourAndCode = $"{txtColourCode.Text.ToUpper()} - {txtColour.Text.ToUpper()}";
         JobColoursModel newJobColour  = new JobColoursModel()
         {
             Colour = colourAndCode
         };
         List <JobColoursModel> colours = PrepAndPaintDB.GetJobColours();
         foreach (var item in colours)
         {
             if (item.Colour == newJobColour.Colour)
             {
                 MessageBox.Show($" Colour: {newJobColour.Colour} already exist", "Exist already!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtColourCode.Focus();
                 return;
             }
         }
         colourName   = PrepAndPaintDB.AddColour(newJobColour);
         DialogResult = DialogResult.OK;
     }
 }
Ejemplo n.º 20
0
 private void BtnAddNewItem_Click(object sender, EventArgs e)
 {
     if (IsValidate())
     {
         char[] a = txtItemName.Text.ToLower().ToCharArray();
         a[0] = char.ToUpper(a[0]);
         ItemsModel newItem = new ItemsModel()
         {
             ItemName = new string(a)
         };
         itemsList = PrepAndPaintDB.GetItemsList();
         foreach (var item in itemsList)
         {
             if (item.ItemName == newItem.ItemName)
             {
                 MessageBox.Show($" Item: {newItem.ItemName} already exist", "Exit already!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtItemName.Focus();
                 return;
             }
         }
         itemName     = PrepAndPaintDB.AddItem(newItem);
         DialogResult = DialogResult.OK;
     }
 }
Ejemplo n.º 21
0
 private void PopulateDataGrid()
 {
     adminDataGridView.DataSource          = PrepAndPaintDB.GetAdmins();
     adminDataGridView.Columns[0].Visible  = false;
     adminDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
 }
Ejemplo n.º 22
0
 private void GetItemList()
 {
     cmboBodyDoors.DisplayMember = "ItemName";
     cmboBodyDoors.DataSource    = PrepAndPaintDB.GetItemsList();
 }
Ejemplo n.º 23
0
 private void PopulateListView()
 {
     itemDataGridView.DataSource         = PrepAndPaintDB.GetItemsList();
     itemDataGridView.Columns[0].Visible = false;
 }
Ejemplo n.º 24
0
 private void PopulateDataGrid()
 {
     colourDataGridView.DataSource          = PrepAndPaintDB.GetJobColours();
     colourDataGridView.Columns[0].Visible  = false;
     colourDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
 }
Ejemplo n.º 25
0
 private void GetColours()
 {
     cmboColour.DisplayMember = "Colour";
     cmboColour.DataSource    = PrepAndPaintDB.GetJobColours();
     cmboColour.SelectedIndex = -1;
 }
Ejemplo n.º 26
0
 private void GetInfo()
 {
     prepAndPaintModels         = PrepAndPaintDB.GetJobLineItems(job.JobNumber);
     jobInfoDataGrid.DataSource = prepAndPaintModels;
     //SetDataGridView();
 }
Ejemplo n.º 27
0
 private void GetInfo()
 {
     prepAndPaintModels      = PrepAndPaintDB.GetNewData();
     dataGridView.DataSource = prepAndPaintModels;
     SetDataGridView();
 }
Ejemplo n.º 28
0
 private void sortToolStripButton_Click(object sender, EventArgs e)
 {
     dataGridView.DataSource = PrepAndPaintDB.SortByDate();
     SetDataGridView();
     txtSearch.Clear();
 }