0% found this document useful (0 votes)
22 views62 pages

New Text Document

Uploaded by

game ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views62 pages

New Text Document

Uploaded by

game ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 62

using OfficeOpenXml;

using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class AuthDepartmentForm : Form
{
private ExcelPackage _package;

public AuthDepartmentForm(ExcelPackage package)


{
InitializeComponent();
_package = package;
ApplyDarkTheme();
LoadSheets();
}

private void ApplyDarkTheme()


{
BackColor = Color.FromArgb(45, 45, 48);
ForeColor = Color.White;
foreach (Control control in Controls)
{
if (control is DataGridView dgv)
{
dgv.BackgroundColor = Color.FromArgb(45, 45, 48);
dgv.GridColor = Color.FromArgb(60, 60, 60);
dgv.DefaultCellStyle.BackColor = Color.FromArgb(45, 45, 48);
dgv.DefaultCellStyle.ForeColor = Color.White;
dgv.DefaultCellStyle.SelectionBackColor = Color.FromArgb(75,
75, 75);
dgv.DefaultCellStyle.SelectionForeColor = Color.White;
dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Orange;
dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
dgv.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 12F,
FontStyle.Bold); // Font mai mic
dgv.ColumnHeadersDefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dgv.ColumnHeadersHeight = 50; // Înălțimea antetului mai mică
dgv.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(45,
45, 48);
dgv.RowHeadersDefaultCellStyle.ForeColor = Color.White;
dgv.RowHeadersDefaultCellStyle.SelectionBackColor =
Color.FromArgb(45, 45, 48);
dgv.RowHeadersDefaultCellStyle.SelectionForeColor =
Color.White;
dgv.EnableHeadersVisualStyles = false;
}
else if (control is Button button)
{
button.BackColor = Color.FromArgb(28, 28, 28);
button.ForeColor = Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
}
}
}

private void LoadSheets()


{
if (_package == null)
{
MessageBox.Show("Please update documents first.");
return;
}

tabControlSheets.TabPages.Clear();

LoadSheet("CarNeedAuth");
LoadSheet("CarsAuthorized");
}

private void LoadSheet(string sheetName)


{
var worksheet = _package.Workbook.Worksheets[sheetName];
if (worksheet == null)
{
MessageBox.Show($"{sheetName} sheet not found in the Excel file.");
return;
}

DataTable dataTable = new DataTable();


foreach (var firstRowCell in worksheet.Cells[1, 1, 1,
worksheet.Dimension.End.Column])
{
dataTable.Columns.Add(firstRowCell.Text);
}

for (var rowNumber = 2; rowNumber <= worksheet.Dimension.End.Row;


rowNumber++)
{
var row = worksheet.Cells[rowNumber, 1, rowNumber,
worksheet.Dimension.End.Column];
var newRow = dataTable.NewRow();

foreach (var cell in row)


{
newRow[cell.Start.Column - 1] = cell.Text;
}
dataTable.Rows.Add(newRow);
}

var tabPage = new TabPage(sheetName);


var dataGridView = new DataGridView
{
Dock = DockStyle.Fill,
DataSource = dataTable,
ReadOnly = true,
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
};

tabPage.Controls.Add(dataGridView);
tabControlSheets.TabPages.Add(tabPage);

ApplyDataGridViewTheme(dataGridView);
}

private void ApplyDataGridViewTheme(DataGridView dgv)


{
dgv.BackgroundColor = Color.FromArgb(45, 45, 48);
dgv.GridColor = Color.FromArgb(60, 60, 60);
dgv.DefaultCellStyle.BackColor = Color.FromArgb(45, 45, 48);
dgv.DefaultCellStyle.ForeColor = Color.White;
dgv.DefaultCellStyle.SelectionBackColor = Color.FromArgb(75, 75, 75);
dgv.DefaultCellStyle.SelectionForeColor = Color.White;
dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Orange;
dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
dgv.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 12F,
FontStyle.Bold); // Font mai mic
dgv.ColumnHeadersDefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dgv.ColumnHeadersHeight = 50; // Înălțimea antetului mai mică
dgv.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(45, 45, 48);
dgv.RowHeadersDefaultCellStyle.ForeColor = Color.White;
dgv.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(45,
45, 48);
dgv.RowHeadersDefaultCellStyle.SelectionForeColor = Color.White;
dgv.EnableHeadersVisualStyles = false;
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class AuthDepartmentForm
{
private System.ComponentModel.IContainer components = null;
private TabControl tabControlSheets;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.tabControlSheets = new TabControl();
this.SuspendLayout();
//
// tabControlSheets
//
this.tabControlSheets.Dock = DockStyle.Fill;
this.tabControlSheets.Location = new System.Drawing.Point(0, 0);
this.tabControlSheets.Name = "tabControlSheets";
this.tabControlSheets.SelectedIndex = 0;
this.tabControlSheets.Size = new System.Drawing.Size(800, 450);
this.tabControlSheets.TabIndex = 0;
//
// AuthDepartmentForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.tabControlSheets);
this.Name = "AuthDepartmentForm";
this.Text = "Auth Department";
this.ResumeLayout(false);
}
}
}
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class DateTimePickerForm : Form
{
public DateTime SelectedDateTime { get; private set; }

public DateTimePickerForm()
{
InitializeComponent();
}

private void btnOk_Click(object sender, EventArgs e)


{
SelectedDateTime = dateTimePicker.Value;
this.DialogResult = DialogResult.OK;
this.Close();
}

private void btnCancel_Click(object sender, EventArgs e)


{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class DateTimePickerForm
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.DateTimePicker dateTimePicker;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// dateTimePicker
//
this.dateTimePicker.CustomFormat = "dd/MM/yyyy HH:mm:ss";
this.dateTimePicker.Format =
System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker.Location = new System.Drawing.Point(12, 12);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(260, 20);
this.dateTimePicker.TabIndex = 0;
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(116, 38);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 1;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(197, 38);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// DateTimePickerForm
//
this.ClientSize = new System.Drawing.Size(284, 71);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.dateTimePicker);
this.Name = "DateTimePickerForm";
this.ResumeLayout(false);

}
}
}
using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OfficeOpenXml;

namespace YourNamespace
{
public partial class DeliveryListForm : Form
{
private Timer _timer;
private bool _toggleColor;
private DataTable _stockListTable;
private ExcelPackage _package;

public DeliveryListForm(ExcelPackage package)


{
InitializeComponent();
_package = package;
ApplyDarkTheme();
InitializeDataGridView();
EnableDoubleBuffering();
InitializeTimer();

txtRegNo.TextChanged += TxtRegNo_TextChanged;
}

private void InitializeTimer()


{
_timer = new Timer { Interval = 1000 };
_timer.Tick += Timer_Tick;
_timer.Start();
}

private void InitializeDataGridView()


{
dataGridView.AllowUserToAddRows = false;
dataGridView.CellPainting += DataGridView_CellPainting;
dataGridView.DataBindingComplete += DataGridView_DataBindingComplete;
dataGridView.EditingControlShowing +=
DataGridView_EditingControlShowing;
dataGridView.CellContentClick += DataGridView_CellContentClick;
dataGridView.DataError += DataGridView_DataError;
}

private void EnableDoubleBuffering()


{
typeof(DataGridView).InvokeMember("DoubleBuffered",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.SetProperty, null, dataGridView, new object[]
{ true });
}

private void DataGridView_DataError(object sender,


DataGridViewDataErrorEventArgs e)
{
e.ThrowException = false;
}

public void LoadDeliveryList(DataTable deliveryTable, DataTable


stockListTable)
{
dataGridView.SuspendLayout();
dataGridView.DataSource = deliveryTable;
_stockListTable = stockListTable;
AddSelectButtonColumn();
AdjustColumnWidths();
PopulateDeliveryList();
ApplyUserAccessControl();
dataGridView.ResumeLayout();
}

private void ApplyUserAccessControl()


{
string loggedInUser = Form1.LoggedInUser;
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["User"].Value?.ToString() != loggedInUser)
{
row.ReadOnly = true;
foreach (DataGridViewCell cell in row.Cells)
{
cell.Style.BackColor = System.Drawing.Color.Gray;
cell.Style.ForeColor = System.Drawing.Color.DarkGray;
}
}
}
}

private void ApplyDarkTheme()


{
SuspendLayout();
BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
ForeColor = System.Drawing.Color.White;
ApplyThemeToControls(Controls);
ResumeLayout();
}

private void ApplyThemeToControls(Control.ControlCollection controls)


{
foreach (Control control in controls)
{
switch (control)
{
case DataGridView dgv:
ApplyDataGridViewTheme(dgv);
break;
case Button button:
ApplyButtonTheme(button);
break;
}
}
}

private void ApplyDataGridViewTheme(DataGridView dgv)


{
dgv.BackgroundColor = System.Drawing.Color.FromArgb(45, 45, 48);
dgv.GridColor = System.Drawing.Color.FromArgb(60, 60, 60);
dgv.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(45, 45,
48);
dgv.DefaultCellStyle.ForeColor = System.Drawing.Color.White;
dgv.DefaultCellStyle.SelectionBackColor =
System.Drawing.Color.FromArgb(75, 75, 75);
dgv.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.White;
dgv.ColumnHeadersDefaultCellStyle.BackColor =
System.Drawing.Color.Orange;
dgv.ColumnHeadersDefaultCellStyle.ForeColor =
System.Drawing.Color.Black;
dgv.ColumnHeadersDefaultCellStyle.Font = new
System.Drawing.Font("Arial", 12F);
dgv.ColumnHeadersDefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dgv.ColumnHeadersHeight = 40;
dgv.RowHeadersDefaultCellStyle.BackColor =
System.Drawing.Color.FromArgb(45, 45, 48);
dgv.RowHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.White;
dgv.RowHeadersDefaultCellStyle.SelectionBackColor =
System.Drawing.Color.FromArgb(45, 45, 48);
dgv.RowHeadersDefaultCellStyle.SelectionForeColor =
System.Drawing.Color.White;
dgv.EnableHeadersVisualStyles = false;
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
}

private void ApplyButtonTheme(Button button)


{
button.BackColor = System.Drawing.Color.FromArgb(28, 28, 28);
button.ForeColor = System.Drawing.Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
}

private void DataGridView_CellPainting(object sender,


DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1 && e.ColumnIndex > -1)
{
e.Graphics.FillRectangle(new
System.Drawing.SolidBrush(System.Drawing.Color.Orange), e.CellBounds);
e.PaintContent(e.CellBounds);
e.Handled = true;
}
}

private void DataGridView_DataBindingComplete(object sender,


DataGridViewBindingCompleteEventArgs e)
{
dataGridView.SuspendLayout();
foreach (DataGridViewRow row in dataGridView.Rows)
{
AddComboBoxToColumn(row, "Williams", new[] { "", "Yes", "No" });
AddComboBoxToColumn(row, "Valet", new[] { "", "In progress",
"Done", "Next" });
AddComboBoxToColumn(row, "Service", new[] { "", "In progress",
"Done", "Next" });
AddComboBoxToColumn(row, "Bodyshop", new[] { "", "In progress",
"Done", "Next", "No need paint" });
}

SetComboBoxColumnWidths();
dataGridView.ResumeLayout();
}

private void SetComboBoxColumnWidths()


{
var columnNames = new[] { "Williams", "Valet", "Service", "Bodyshop" };
foreach (var columnName in columnNames)
{
if (dataGridView.Columns[columnName] != null)
{
dataGridView.Columns[columnName].Width = 90;
}
}
}

private void AddComboBoxToColumn(DataGridViewRow row, string columnName,


string[] options)
{
if (row.Cells[columnName] is DataGridViewTextBoxCell)
{
DataGridViewComboBoxCell comboBoxCell = new
DataGridViewComboBoxCell
{
FlatStyle = FlatStyle.Flat,
Style = new DataGridViewCellStyle
{
BackColor = System.Drawing.Color.FromArgb(45, 45, 48),
ForeColor = System.Drawing.Color.White,
SelectionBackColor = System.Drawing.Color.FromArgb(75, 75,
75),
SelectionForeColor = System.Drawing.Color.White
}
};
comboBoxCell.Items.AddRange(options);
comboBoxCell.Value = row.Cells[columnName].Value;
row.Cells[columnName] = comboBoxCell;
}
}

private void AddSelectButtonColumn()


{
if (!dataGridView.Columns.Contains("SelectButtonColumn"))
{
DataGridViewButtonColumn selectButtonColumn = new
DataGridViewButtonColumn
{
Name = "SelectButtonColumn",
HeaderText = "Select D/T",
Text = "Select",
UseColumnTextForButtonValue = true,
FlatStyle = FlatStyle.Flat
};
dataGridView.Columns.Insert(dataGridView.Columns["User"].Index + 1,
selectButtonColumn);
}
}

private void DataGridView_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && dataGridView.Columns[e.ColumnIndex].Name ==
"SelectButtonColumn")
{
using (DateTimePickerForm dateTimePickerForm = new
DateTimePickerForm())
{
if (dateTimePickerForm.ShowDialog() == DialogResult.OK)
{
dataGridView.Rows[e.RowIndex].Cells["Date & time"].Value =
dateTimePickerForm.SelectedDateTime.ToString("dd/MM/yyyy HH:mm:ss");
}
}
}
}

private void DataGridView_EditingControlShowing(object sender,


DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is ComboBox comboBox)
{
comboBox.SelectedIndexChanged -= ComboBox_SelectedIndexChanged;
comboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
}
}

private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)


{
if (sender is ComboBox comboBox && comboBox.SelectedItem != null)
{
DataGridViewComboBoxEditingControl editingControl = comboBox as
DataGridViewComboBoxEditingControl;
if (editingControl != null)
{
DataGridViewRow row =
editingControl.EditingControlDataGridView.CurrentRow;
ApplyRowStyle(row);
}
}
}

private void ApplyRowStyle(DataGridViewRow row)


{
bool isDoneConditionMet = CheckDoneCondition(row);
bool inProgress = false;
bool next = false;

foreach (DataGridViewCell cell in row.Cells)


{
if (cell is DataGridViewComboBoxCell comboBoxCell &&
comboBoxCell.Value != null)
{
if (comboBoxCell.Value.ToString() == "In progress")
{
inProgress = true;
break;
}
if (comboBoxCell.Value.ToString() == "Next")
{
next = true;
break;
}
}
}
if (isDoneConditionMet)
{
SetRowStyle(row, System.Drawing.Color.Green,
System.Drawing.Color.White);
}
else if (inProgress)
{
SetRowStyle(row, System.Drawing.Color.LightGreen,
System.Drawing.Color.Red);
}
else if (next)
{
SetRowStyle(row, System.Drawing.Color.Orange,
System.Drawing.Color.Black);
}
else
{
SetRowStyle(row, System.Drawing.Color.FromArgb(45, 45, 48),
System.Drawing.Color.White);
}

ApplyBlueColorForYes(row);
}

private void SetRowStyle(DataGridViewRow row, System.Drawing.Color


backColor, System.Drawing.Color foreColor)
{
foreach (DataGridViewCell cell in row.Cells)
{
cell.Style.BackColor = backColor;
cell.Style.ForeColor = foreColor;
}
}

private void ApplyBlueColorForYes(DataGridViewRow row)


{
if (row.Cells["Williams"] is DataGridViewComboBoxCell yesComboBoxCell
&& yesComboBoxCell.Value != null && yesComboBoxCell.Value.ToString() == "Yes")
{
yesComboBoxCell.Style.BackColor = System.Drawing.Color.Blue;
yesComboBoxCell.Style.ForeColor = System.Drawing.Color.White;
}
}

private bool CheckDoneCondition(DataGridViewRow row)


{
return row.Cells["Valet"].Value?.ToString() == "Done" &&
row.Cells["Service"].Value?.ToString() == "Done" &&
(row.Cells["Bodyshop"].Value?.ToString() == "Done" ||
row.Cells["Bodyshop"].Value?.ToString() == "No need paint");
}

private void Timer_Tick(object sender, EventArgs e)


{
dataGridView.SuspendLayout();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells.Cast<DataGridViewCell>().Any(cell => cell.Value !=
null && !string.IsNullOrWhiteSpace(cell.Value.ToString())))
{
bool isDoneConditionMet = CheckDoneCondition(row);
bool isInProgress = row.Cells.Cast<DataGridViewCell>().Any(cell
=> cell.Value?.ToString() == "In progress");
bool isNext = row.Cells.Cast<DataGridViewCell>().Any(cell =>
cell.Value?.ToString() == "Next");

if (isDoneConditionMet)
{
SetRowStyle(row, System.Drawing.Color.Green,
System.Drawing.Color.White);
}
else if (isInProgress)
{
SetAlternatingRowStyle(row,
System.Drawing.Color.LightGreen, System.Drawing.Color.Red);
}
else if (isNext)
{
SetAlternatingRowStyle(row, System.Drawing.Color.Orange,
System.Drawing.Color.Black);
}
else
{
SetRowStyle(row, System.Drawing.Color.FromArgb(45, 45, 48),
System.Drawing.Color.White);
}

ApplyBlueColorForYes(row);
}
}
_toggleColor = !_toggleColor;
dataGridView.ResumeLayout();
}

private void SetAlternatingRowStyle(DataGridViewRow row,


System.Drawing.Color backColor, System.Drawing.Color foreColor)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (_toggleColor)
{
cell.Style.BackColor = backColor;
cell.Style.ForeColor = foreColor;
}
else
{
cell.Style.BackColor = System.Drawing.Color.FromArgb(45, 45,
48);
cell.Style.ForeColor = System.Drawing.Color.White;
}
}
}

private void AdjustColumnWidths()


{

dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
dataGridView.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells);
}

private void PopulateDeliveryList()


{
dataGridView.SuspendLayout();
foreach (DataGridViewRow deliveryRow in dataGridView.Rows)
{
string regNo = deliveryRow.Cells["RegNo"].Value?.ToString();
if (string.IsNullOrEmpty(regNo)) continue;

DataRow[] foundRows = _stockListTable.Select($"RegNo = '{regNo}'");


if (foundRows.Length > 0)
{
DataRow stockRow = foundRows[0];
deliveryRow.Cells["StockNo"].Value = stockRow["StockNo"];
deliveryRow.Cells["PegNo"].Value = stockRow["PegNo"];
deliveryRow.Cells["Make"].Value = stockRow["Make"];
deliveryRow.Cells["Model"].Value = stockRow["Model"];
deliveryRow.Cells["Colour"].Value = stockRow["Colour"];
deliveryRow.Cells["Type clean"].Value = stockRow["Type clean"];
}

if
(string.IsNullOrWhiteSpace(Convert.ToString(deliveryRow.Cells["Type
clean"].Value)))
{
deliveryRow.Cells["Type clean"].Value = "Full valet";
deliveryRow.Cells["Type clean"].Style.ForeColor =
System.Drawing.Color.Red;
}
}
dataGridView.ResumeLayout();
}

private void btnAddSoldCar_Click(object sender, EventArgs e)


{
if (MessageBox.Show("Are you sure you want to add this car?",
"Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}

string regNo = txtRegNo.Text;


if (string.IsNullOrWhiteSpace(regNo))
{
MessageBox.Show("Please enter a registration number.");
return;
}

// Verifică dacă numărul de înmatriculare există deja în dataGridView


foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["RegNo"].Value?.ToString() == regNo)
{
MessageBox.Show("This registration number is already added.");
return;
}
}
DataRow[] foundRows = _stockListTable.Select($"RegNo = '{regNo}'");
if (foundRows.Length == 0)
{
MessageBox.Show("Registration number not found.");
return;
}

DataRow stockRow = foundRows[0];


DataTable deliveryTable = (DataTable)dataGridView.DataSource;

DataRow newRow = deliveryTable.NewRow();


foreach (DataColumn column in deliveryTable.Columns)
{
if (stockRow.Table.Columns.Contains(column.ColumnName))
{
newRow[column.ColumnName] = stockRow[column.ColumnName];
}
}

newRow["RegNo"] = regNo; // Asigură-te că adaugi RegNo corect


newRow["User"] = Form1.LoggedInUser;

deliveryTable.Rows.Add(newRow);

var newRowInGrid = dataGridView.Rows[dataGridView.Rows.Count - 1];

if (string.IsNullOrWhiteSpace(Convert.ToString(newRowInGrid.Cells["Type
clean"].Value)))
{
newRowInGrid.Cells["Type clean"].Value = "Full valet";
newRowInGrid.Cells["Type clean"].Style.ForeColor =
System.Drawing.Color.Red;
}
}

private void btnRemoveCar_Click(object sender, EventArgs e)


{
if (MessageBox.Show("Are you sure you want to remove this car?",
"Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}

if (dataGridView.SelectedRows.Count > 0)
{
foreach (DataGridViewRow row in dataGridView.SelectedRows)
{
dataGridView.Rows.Remove(row);
}
}
else
{
MessageBox.Show("Please select a row to remove.");
}
}

private void btnSaveList_Click(object sender, EventArgs e)


{
if (MessageBox.Show("Are you sure you want to save the list?",
"Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}

SaveDeliveryList();
}

private void SaveDeliveryList()


{
var worksheet = _package.Workbook.Worksheets["SavedList"];
if (worksheet == null)
{
worksheet = _package.Workbook.Worksheets.Add("SavedList");
}

string currentDate = DateTime.Now.ToString("dd/MM/yyyy");

// Caută dacă există deja o salvare pentru data curentă


bool foundExisting = false;
int startRow = worksheet.Dimension?.End.Row + 2 ?? 2; // Începe la
sfârșitul foii sau de la rândul 2 dacă foaia este goală

for (int row = 2; row <= worksheet.Dimension?.End.Row; row++)


{
if (worksheet.Cells[row, 1].Text == currentDate)
{
startRow = row;
foundExisting = true;
break;
}
}

if (foundExisting)
{
// Șterge rândurile existente pentru data curentă
int endRow = startRow;
while (endRow <= worksheet.Dimension.End.Row &&
worksheet.Cells[endRow, 1].Text == currentDate)
{
endRow++;
}
worksheet.DeleteRow(startRow, endRow - startRow);
}

// Adaugă o linie goală înainte de a adăuga noile date, dacă este


necesar
if (startRow > 2)
{
worksheet.InsertRow(startRow, 1);
startRow++;
}

// Scrie data curentă pe primul rând


worksheet.Cells[startRow, 1].Value = "Date Saved:";
worksheet.Cells[startRow, 2].Value = currentDate;
startRow++;
// Scrie anteturile de coloană
for (int i = 0; i < dataGridView.Columns.Count; i++)
{
worksheet.Cells[startRow, i + 1].Value =
dataGridView.Columns[i].HeaderText;
}

// Scrie datele din DataGridView în worksheet


for (int rowIndex = 0; rowIndex < dataGridView.Rows.Count; rowIndex++)
{
for (int colIndex = 0; colIndex < dataGridView.Columns.Count;
colIndex++)
{
worksheet.Cells[startRow + rowIndex + 1, colIndex + 1].Value =
dataGridView.Rows[rowIndex].Cells[colIndex].Value?.ToString();
}
}

_package.Save();
MessageBox.Show("List saved successfully.");
}

private void TxtRegNo_TextChanged(object sender, EventArgs e)


{
txtRegNo.Text = txtRegNo.Text.ToUpper();
txtRegNo.SelectionStart = txtRegNo.Text.Length;
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class DeliveryListForm
{
private System.ComponentModel.IContainer components = null;
private DataGridView dataGridView;
private TextBox txtRegNo;
private Button btnAddSoldCar;
private Button btnSaveList;
private Button btnRemoveCar;
private Panel controlPanel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.dataGridView = new DataGridView();
this.txtRegNo = new TextBox();
this.btnAddSoldCar = new Button();
this.btnSaveList = new Button();
this.btnRemoveCar = new Button();
this.controlPanel = new Panel();
((System.ComponentModel.ISupportInitialize)
(this.dataGridView)).BeginInit();
this.SuspendLayout();

// controlPanel
this.controlPanel.Dock = DockStyle.Right;
this.controlPanel.Width = 200;
this.controlPanel.Controls.Add(this.txtRegNo);
this.controlPanel.Controls.Add(this.btnAddSoldCar);
this.controlPanel.Controls.Add(this.btnSaveList);
this.controlPanel.Controls.Add(this.btnRemoveCar);

// txtRegNo
this.txtRegNo.Location = new System.Drawing.Point(10, 20);
this.txtRegNo.Name = "txtRegNo";
this.txtRegNo.Size = new System.Drawing.Size(180, 20);

// btnAddSoldCar
this.btnAddSoldCar.Location = new System.Drawing.Point(10, 50);
this.btnAddSoldCar.Name = "btnAddSoldCar";
this.btnAddSoldCar.Size = new System.Drawing.Size(180, 30);
this.btnAddSoldCar.Text = "Add Sold Car";
this.btnAddSoldCar.UseVisualStyleBackColor = true;
this.btnAddSoldCar.ForeColor = System.Drawing.Color.Black;
this.btnAddSoldCar.Click += new
System.EventHandler(this.btnAddSoldCar_Click);

// btnSaveList
this.btnSaveList.Location = new System.Drawing.Point(10, 90);
this.btnSaveList.Name = "btnSaveList";
this.btnSaveList.Size = new System.Drawing.Size(180, 30);
this.btnSaveList.Text = "Save List";
this.btnSaveList.UseVisualStyleBackColor = true;
this.btnSaveList.ForeColor = System.Drawing.Color.Black;
this.btnSaveList.Click += new
System.EventHandler(this.btnSaveList_Click);

// btnRemoveCar
this.btnRemoveCar.Location = new System.Drawing.Point(10, 130);
this.btnRemoveCar.Name = "btnRemoveCar";
this.btnRemoveCar.Size = new System.Drawing.Size(180, 30);
this.btnRemoveCar.Text = "Remove Car";
this.btnRemoveCar.UseVisualStyleBackColor = true;
this.btnRemoveCar.ForeColor = System.Drawing.Color.Black;
this.btnRemoveCar.Click += new
System.EventHandler(this.btnRemoveCar_Click);

// dataGridView
this.dataGridView.ColumnHeadersHeightSizeMode =
DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
this.dataGridView.ColumnHeadersHeight = 40;
this.dataGridView.Dock = DockStyle.Fill;
this.dataGridView.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.Size = new System.Drawing.Size(600, 450);
this.dataGridView.TabIndex = 0;
// DeliveryListForm
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.controlPanel);
this.Name = "DeliveryListForm";
this.Text = "Delivery List";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class Form1 : Form
{
public static string LoggedInUser { get; private set; }

public Form1()
{
InitializeComponent();
ApplyDarkTheme();
}

private void btnLogin_Click(object sender, EventArgs e)


{
string username = txtUsername.Text;
string password = txtPassword.Text;

if (username == "admin" && password == "password")


{
LoggedInUser = username;
MainForm mainForm = new MainForm();
mainForm.Show();
this.Hide();
mainForm.FormClosed += (s, args) => this.Show();
}
else
{
MessageBox.Show("Username sau parola incorectă!");
}
}

private void ApplyDarkTheme()


{
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ForeColor = System.Drawing.Color.White;
foreach (Control control in this.Controls)
{
if (control is TextBox)
{
control.BackColor = System.Drawing.Color.FromArgb(30, 30, 30);
control.ForeColor = System.Drawing.Color.White;
}
else if (control is Button)
{
control.BackColor = System.Drawing.Color.FromArgb(28, 28, 28);
control.ForeColor = System.Drawing.Color.White;
((Button)control).FlatStyle = FlatStyle.Flat;
((Button)control).FlatAppearance.BorderSize = 0;
((Button)control).MouseEnter += new
EventHandler(Button_MouseEnter);
((Button)control).MouseLeave += new
EventHandler(Button_MouseLeave);
}
}
}

private void Button_MouseEnter(object sender, EventArgs e)


{
Button button = sender as Button;
if (button != null)
{
button.Tag = button.BackColor;
button.BackColor = System.Drawing.Color.Orange;
button.ForeColor = System.Drawing.Color.Black;
}
}

private void Button_MouseLeave(object sender, EventArgs e)


{
Button button = sender as Button;
if (button != null)
{
button.BackColor = (System.Drawing.Color)button.Tag;
button.ForeColor = System.Drawing.Color.White;
}
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
private TextBox txtUsername;
private TextBox txtPassword;
private Button btnLogin;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.txtUsername = new TextBox();
this.txtPassword = new TextBox();
this.btnLogin = new Button();
this.SuspendLayout();

// txtUsername
this.txtUsername.Location = new System.Drawing.Point(100, 50);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(200, 20);
this.txtUsername.TabIndex = 0;

// txtPassword
this.txtPassword.Location = new System.Drawing.Point(100, 100);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(200, 20);
this.txtPassword.TabIndex = 1;
this.txtPassword.UseSystemPasswordChar = true;

// btnLogin
this.btnLogin.Location = new System.Drawing.Point(150, 150);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(100, 30);
this.btnLogin.TabIndex = 2;
this.btnLogin.Text = "Login";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);

// Form1
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(400, 250);
this.Controls.Add(this.txtUsername);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.btnLogin);
this.Name = "Form1";
this.Text = "Login";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using OfficeOpenXml;
using System;
using System.Data;
using System.Drawing; // Adăugați acest using pentru a accesa clasa Color
using System.Windows.Forms;

namespace YourNamespace
{
public partial class MainForm : Form
{
private ExcelPackage _package;
private DataTable _stockListTable;
private ManagementForm _managementForm;

public MainForm()
{
InitializeComponent();
ApplyDarkTheme();
}
private void MainForm_Load(object sender, EventArgs e)
{
SetButtonEvents();
}

private void SetButtonEvents()


{
btnManagement.MouseEnter += Button_MouseEnter;
btnManagement.MouseLeave += Button_MouseLeave;
btnDeliveryList.MouseEnter += Button_MouseEnter;
btnDeliveryList.MouseLeave += Button_MouseLeave;
btnValeting.MouseEnter += Button_MouseEnter;
btnValeting.MouseLeave += Button_MouseLeave;
btnUpdateDocuments.MouseEnter += Button_MouseEnter;
btnUpdateDocuments.MouseLeave += Button_MouseLeave;
btnAuthDepartment.MouseEnter += Button_MouseEnter;
btnAuthDepartment.MouseLeave += Button_MouseLeave;
btnLogout.MouseEnter += Button_MouseEnter;
btnLogout.MouseLeave += Button_MouseLeave;
btnExit.MouseEnter += Button_MouseEnter;
btnExit.MouseLeave += Button_MouseLeave;

btnUpdateDocuments.Click += btnUpdateDocuments_Click;
btnDeliveryList.Click += btnDeliveryList_Click;
btnLogout.Click += btnLogout_Click;
btnExit.Click += btnExit_Click;
btnManagement.Click += btnManagement_Click;
btnValeting.Click += btnValeting_Click;
btnAuthDepartment.Click += btnAuthDepartment_Click;
}

private void btnUpdateDocuments_Click(object sender, EventArgs e)


{
UpdateDocumentsForm updateDocumentsForm = new UpdateDocumentsForm
{
Owner = this
};
updateDocumentsForm.ShowDialog();
}

private void btnManagement_Click(object sender, EventArgs e)


{
if (_managementForm == null || _managementForm.IsDisposed)
{
_managementForm = new ManagementForm();
_managementForm.SetExcelPackage(_package);
_managementForm.Show();
}
else
{
_managementForm.BringToFront();
}
}

private void btnAuthDepartment_Click(object sender, EventArgs e)


{
if (_package == null)
{
MessageBox.Show("Please update documents first.");
return;
}

AuthDepartmentForm authDepartmentForm = new


AuthDepartmentForm(_package);
authDepartmentForm.ShowDialog();
}

public void SetExcelPackage(ExcelPackage package)


{
_package = package;
LoadStockListTable();
}

private void LoadStockListTable()


{
var worksheet = _package.Workbook.Worksheets["StockList"];
if (worksheet == null)
{
MessageBox.Show("StockList sheet not found in the Excel file.");
return;
}

_stockListTable = new DataTable();


foreach (var firstRowCell in worksheet.Cells[1, 1, 1,
worksheet.Dimension.End.Column])
{
_stockListTable.Columns.Add(firstRowCell.Text);
}

for (var rowNumber = 2; rowNumber <= worksheet.Dimension.End.Row;


rowNumber++)
{
var row = worksheet.Cells[rowNumber, 1, rowNumber,
worksheet.Dimension.End.Column];
var newRow = _stockListTable.NewRow();

foreach (var cell in row)


{
newRow[cell.Start.Column - 1] = cell.Text;
}
_stockListTable.Rows.Add(newRow);
}
}

private void btnDeliveryList_Click(object sender, EventArgs e)


{
if (_package == null)
{
MessageBox.Show("Please update documents first.");
return;
}

var deliverySheet = _package.Workbook.Worksheets["DeliveryList"];


if (deliverySheet == null)
{
MessageBox.Show("DeliveryList sheet not found in the Excel file.");
return;
}

DataTable deliveryTable = new DataTable();


foreach (var firstRowCell in deliverySheet.Cells[1, 1, 1,
deliverySheet.Dimension.End.Column])
{
deliveryTable.Columns.Add(firstRowCell.Text);
}

for (var rowNum = 2; rowNum <= deliverySheet.Dimension.End.Row; rowNum+


+)
{
var wsRow = deliverySheet.Cells[rowNum, 1, rowNum,
deliverySheet.Dimension.End.Column];
DataRow row = deliveryTable.NewRow();
foreach (var cell in wsRow)
{
row[cell.Start.Column - 1] = cell.Text;
}
deliveryTable.Rows.Add(row);
}

DeliveryListForm deliveryListForm = new DeliveryListForm(_package);


deliveryListForm.LoadDeliveryList(deliveryTable, _stockListTable);
deliveryListForm.ShowDialog();
}

private void btnValeting_Click(object sender, EventArgs e)


{
if (_package == null)
{
MessageBox.Show("Please update documents first.");
return;
}

ValetingForm valetingForm = new ValetingForm(_package);


valetingForm.ShowDialog();
}

private void Button_MouseEnter(object sender, EventArgs e)


{
if (sender is Button button)
{
button.Tag = button.BackColor;
button.BackColor = Color.Orange;
button.ForeColor = Color.Black;
}
}

private void Button_MouseLeave(object sender, EventArgs e)


{
if (sender is Button button)
{
button.BackColor = (Color)button.Tag;
button.ForeColor = Color.White;
}
}

private void ApplyDarkTheme()


{
BackColor = Color.FromArgb(45, 45, 48);
ForeColor = Color.White;
foreach (Control control in Controls)
{
if (control is Button button)
{
button.BackColor = Color.FromArgb(28, 28, 28);
button.ForeColor = Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
}
}
}

private void btnLogout_Click(object sender, EventArgs e)


{
Hide();
Form1 loginForm = new Form1();
loginForm.Show();
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class MainForm
{
private System.ComponentModel.IContainer components = null;
private Button btnManagement;
private Button btnDeliveryList;
private Button btnValeting;
private Button btnUpdateDocuments;
private Button btnAuthDepartment;
private Button btnLogout;
private Button btnExit;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.btnManagement = new Button();
this.btnDeliveryList = new Button();
this.btnValeting = new Button();
this.btnUpdateDocuments = new Button();
this.btnAuthDepartment = new Button();
this.btnLogout = new Button();
this.btnExit = new Button();
this.SuspendLayout();

// btnManagement
this.btnManagement.Location = new System.Drawing.Point(50, 20);
this.btnManagement.Name = "btnManagement";
this.btnManagement.Size = new System.Drawing.Size(200, 40);
this.btnManagement.TabIndex = 0;
this.btnManagement.Text = "Management";
this.btnManagement.UseVisualStyleBackColor = true;

// btnDeliveryList
this.btnDeliveryList.Location = new System.Drawing.Point(50, 70);
this.btnDeliveryList.Name = "btnDeliveryList";
this.btnDeliveryList.Size = new System.Drawing.Size(200, 40);
this.btnDeliveryList.TabIndex = 1;
this.btnDeliveryList.Text = "Delivery List";

// btnValeting
this.btnValeting.Location = new System.Drawing.Point(50, 120);
this.btnValeting.Name = "btnValeting";
this.btnValeting.Size = new System.Drawing.Size(200, 40);
this.btnValeting.TabIndex = 2;
this.btnValeting.Text = "Valeting";

// btnUpdateDocuments
this.btnUpdateDocuments.Location = new System.Drawing.Point(50, 170);
this.btnUpdateDocuments.Name = "btnUpdateDocuments";
this.btnUpdateDocuments.Size = new System.Drawing.Size(200, 40);
this.btnUpdateDocuments.TabIndex = 3;
this.btnUpdateDocuments.Text = "Update Documents";

// btnAuthDepartment
this.btnAuthDepartment.Location = new System.Drawing.Point(50, 220);
this.btnAuthDepartment.Name = "btnAuthDepartment";
this.btnAuthDepartment.Size = new System.Drawing.Size(200, 40);
this.btnAuthDepartment.TabIndex = 4;
this.btnAuthDepartment.Text = "Auth Department";

// btnLogout
this.btnLogout.Location = new System.Drawing.Point(50, 270);
this.btnLogout.Name = "btnLogout";
this.btnLogout.Size = new System.Drawing.Size(200, 40);
this.btnLogout.TabIndex = 5;
this.btnLogout.Text = "Logout";

// btnExit
this.btnExit.Location = new System.Drawing.Point(50, 320);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(200, 40);
this.btnExit.TabIndex = 6;
this.btnExit.Text = "Exit";

// MainForm
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 400);
this.Controls.Add(this.btnManagement);
this.Controls.Add(this.btnDeliveryList);
this.Controls.Add(this.btnValeting);
this.Controls.Add(this.btnUpdateDocuments);
this.Controls.Add(this.btnAuthDepartment);
this.Controls.Add(this.btnLogout);
this.Controls.Add(this.btnExit);
this.Name = "MainForm";
this.Text = "Main Form";
this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false);
}
}
}
using System;
using System.Windows.Forms;
using OfficeOpenXml;

namespace YourNamespace
{
public partial class ManagementForm : Form
{
private ExcelPackage _package;

public ManagementForm()
{
InitializeComponent();
ApplyDarkTheme();
}

public void SetExcelPackage(ExcelPackage package)


{
_package = package;
}

private void btnUsersSettings_Click(object sender, EventArgs e)


{
using (UserSettingsForm userSettingsForm = new UserSettingsForm())
{
userSettingsForm.SetExcelPackage(_package);
userSettingsForm.ShowDialog();
}
}

private void btnRegisterUser_Click(object sender, EventArgs e)


{
using (RegisterUserForm registerUserForm = new RegisterUserForm())
{
registerUserForm.SetExcelPackage(_package);
registerUserForm.ShowDialog();
}
}

private void btnValetingProgress_Click(object sender, EventArgs e)


{
if (_package == null)
{
MessageBox.Show("Please update documents first.");
return;
}
ValetingProgressForm valetingProgressForm = new
ValetingProgressForm(_package);
valetingProgressForm.ShowDialog();
}

private void ApplyDarkTheme()


{
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ForeColor = System.Drawing.Color.White;

foreach (Control control in this.Controls)


{
ApplyThemeToControl(control);
}
}

private void ApplyThemeToControl(Control control)


{
switch (control)
{
case Button button:
button.BackColor = System.Drawing.Color.FromArgb(28, 28, 28);
button.ForeColor = System.Drawing.Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
break;
case TextBox textBox:
textBox.BackColor = System.Drawing.Color.FromArgb(30, 30, 30);
textBox.ForeColor = System.Drawing.Color.White;
break;
case Label label:
label.ForeColor = System.Drawing.Color.White;
break;
}

foreach (Control child in control.Controls)


{
ApplyThemeToControl(child);
}
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ManagementForm
{
private System.ComponentModel.IContainer components = null;
private Button btnUsersSettings;
private Button btnRegisterUser;
private Button btnValetingProgress;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.btnUsersSettings = new Button();
this.btnRegisterUser = new Button();
this.btnValetingProgress = new Button();
this.SuspendLayout();
//
// btnUsersSettings
//
this.btnUsersSettings.Location = new System.Drawing.Point(50, 50);
this.btnUsersSettings.Name = "btnUsersSettings";
this.btnUsersSettings.Size = new System.Drawing.Size(200, 40);
this.btnUsersSettings.TabIndex = 0;
this.btnUsersSettings.Text = "Users Settings";
this.btnUsersSettings.UseVisualStyleBackColor = true;
this.btnUsersSettings.Click += new
System.EventHandler(this.btnUsersSettings_Click);
//
// btnRegisterUser
//
this.btnRegisterUser.Location = new System.Drawing.Point(50, 100);
this.btnRegisterUser.Name = "btnRegisterUser";
this.btnRegisterUser.Size = new System.Drawing.Size(200, 40);
this.btnRegisterUser.TabIndex = 1;
this.btnRegisterUser.Text = "Register User";
this.btnRegisterUser.UseVisualStyleBackColor = true;
this.btnRegisterUser.Click += new
System.EventHandler(this.btnRegisterUser_Click);
//
// btnValetingProgress
//
this.btnValetingProgress.Location = new System.Drawing.Point(50, 150);
this.btnValetingProgress.Name = "btnValetingProgress";
this.btnValetingProgress.Size = new System.Drawing.Size(200, 40);
this.btnValetingProgress.TabIndex = 2;
this.btnValetingProgress.Text = "Valeting Progress";
this.btnValetingProgress.UseVisualStyleBackColor = true;
this.btnValetingProgress.Click += new
System.EventHandler(this.btnValetingProgress_Click);
//
// ManagementForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 200);
this.Controls.Add(this.btnRegisterUser);
this.Controls.Add(this.btnUsersSettings);
this.Controls.Add(this.btnValetingProgress);
this.Name = "ManagementForm";
this.Text = "Management";
this.ResumeLayout(false);
}
}
}
using OfficeOpenXml;
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class ManagerCodeForm : Form
{
private ExcelPackage package;
private string stockListData;
private string mvInvoiceData;

public ManagerCodeForm(ExcelPackage package, string stockListData, string


mvInvoiceData)
{
InitializeComponent();
this.package = package;
this.stockListData = stockListData;
this.mvInvoiceData = mvInvoiceData;
ApplyDarkTheme();
DisplayData();
}

private void ApplyDarkTheme()


{
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ForeColor = System.Drawing.Color.White;
foreach (Control control in this.Controls)
{
if (control is TextBox textBox)
{
textBox.BackColor = System.Drawing.Color.FromArgb(30, 30, 30);
textBox.ForeColor = System.Drawing.Color.Red;
}
else if (control is Button button)
{
button.BackColor = System.Drawing.Color.FromArgb(28, 28, 28);
button.ForeColor = System.Drawing.Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
}
else if (control is Label)
{
control.ForeColor = System.Drawing.Color.White;
}
}
}

private void DisplayData()


{
if (!string.IsNullOrEmpty(stockListData))
{
lblStockListData.Text = "StockList Data: " + stockListData;
}

if (!string.IsNullOrEmpty(mvInvoiceData))
{
lblMvInvoiceData.Text = "MVinvoice Data: " + mvInvoiceData;
}
}
private void BtnOk_Click(object sender, EventArgs e)
{
var sheet = package.Workbook.Worksheets["ManagerCode"];
bool isValidCode = false;

for (int row = 2; row <= sheet.Dimension.End.Row; row++)


{
if (sheet.Cells[row, 1].Text.Equals(txtManagerCode.Text,
StringComparison.OrdinalIgnoreCase))
{
isValidCode = true;
break;
}
}

if (isValidCode)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
MessageBox.Show("Invalid Manager Code.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void BtnCancel_Click(object sender, EventArgs e)


{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ManagerCodeForm
{
private System.ComponentModel.IContainer components = null;
private Label lblStockListData;
private Label lblMvInvoiceData;
private TextBox txtManagerCode;
private Button btnOk;
private Button btnCancel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblStockListData = new System.Windows.Forms.Label();
this.lblMvInvoiceData = new System.Windows.Forms.Label();
this.txtManagerCode = new System.Windows.Forms.TextBox();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblStockListData
//
this.lblStockListData.AutoSize = true;
this.lblStockListData.Location = new System.Drawing.Point(12, 9);
this.lblStockListData.Name = "lblStockListData";
this.lblStockListData.Size = new System.Drawing.Size(0, 13);
this.lblStockListData.TabIndex = 0;
//
// lblMvInvoiceData
//
this.lblMvInvoiceData.AutoSize = true;
this.lblMvInvoiceData.Location = new System.Drawing.Point(12, 32);
this.lblMvInvoiceData.Name = "lblMvInvoiceData";
this.lblMvInvoiceData.Size = new System.Drawing.Size(0, 13);
this.lblMvInvoiceData.TabIndex = 1;
//
// txtManagerCode
//
this.txtManagerCode.Location = new System.Drawing.Point(15, 58);
this.txtManagerCode.Name = "txtManagerCode";
this.txtManagerCode.Size = new System.Drawing.Size(257, 20);
this.txtManagerCode.TabIndex = 2;
this.txtManagerCode.UseSystemPasswordChar = true;
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(15, 94);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 3;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.BtnOk_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(197, 94);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// ManagerCodeForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ClientSize = new System.Drawing.Size(284, 129);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.txtManagerCode);
this.Controls.Add(this.lblMvInvoiceData);
this.Controls.Add(this.lblStockListData);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ManagerCodeForm";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Manager Code";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using OfficeOpenXml;

namespace YourNamespace
{
public partial class ManualEntryForm : Form
{
private ExcelPackage package;
private string registrationNumber;

public ManualEntryForm(ExcelPackage package, string registrationNumber)


{
InitializeComponent();
this.package = package;
this.registrationNumber = registrationNumber;
LoadReasons();
}

private void LoadReasons()


{
var sheet = package.Workbook.Worksheets["Reason"];
var reasons = new List<string>();

for (int row = 2; row <= sheet.Dimension.End.Row; row++)


{
reasons.Add(sheet.Cells[row, 1].Text);
}

cmbReason.DataSource = reasons;
}

private void BtnNext_Click(object sender, EventArgs e)


{
if (string.IsNullOrWhiteSpace(txtManagerCode.Text))
{
MessageBox.Show("Please enter the Manager Code to proceed.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var managerCodeSheet = package.Workbook.Worksheets["ManagerCode"];
bool isValidCode = false;

for (int row = 2; row <= managerCodeSheet.Dimension.End.Row; row++)


{
if (managerCodeSheet.Cells[row, 1].Text.Equals(txtManagerCode.Text,
StringComparison.OrdinalIgnoreCase))
{
isValidCode = true;
break;
}
}

if (!isValidCode)
{
MessageBox.Show("Invalid Manager Code.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

var valetingDetailsForm = new ValetingDetailsForm(package,


registrationNumber);
valetingDetailsForm.ShowDialog();
}

private void BtnCancel_Click(object sender, EventArgs e)


{
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ManualEntryForm
{
private System.ComponentModel.IContainer components = null;
private Label lblStockNo;
private Label lblMake;
private Label lblModel;
private Label lblReason;
private Label lblManagerCode;
private TextBox txtStockNo;
private TextBox txtMake;
private TextBox txtModel;
private TextBox txtManagerCode;
private ComboBox cmbReason;
private Button btnNext;
private Button btnCancel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lblStockNo = new System.Windows.Forms.Label();
this.lblMake = new System.Windows.Forms.Label();
this.lblModel = new System.Windows.Forms.Label();
this.lblReason = new System.Windows.Forms.Label();
this.lblManagerCode = new System.Windows.Forms.Label();
this.txtStockNo = new System.Windows.Forms.TextBox();
this.txtMake = new System.Windows.Forms.TextBox();
this.txtModel = new System.Windows.Forms.TextBox();
this.txtManagerCode = new System.Windows.Forms.TextBox();
this.cmbReason = new System.Windows.Forms.ComboBox();
this.btnNext = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblStockNo
//
this.lblStockNo.AutoSize = true;
this.lblStockNo.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblStockNo.ForeColor = System.Drawing.Color.White;
this.lblStockNo.Location = new System.Drawing.Point(12, 9);
this.lblStockNo.Name = "lblStockNo";
this.lblStockNo.Size = new System.Drawing.Size(85, 20);
this.lblStockNo.TabIndex = 0;
this.lblStockNo.Text = "Stock No";
//
// txtStockNo
//
this.txtStockNo.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F);
this.txtStockNo.Location = new System.Drawing.Point(16, 32);
this.txtStockNo.Name = "txtStockNo";
this.txtStockNo.Size = new System.Drawing.Size(360, 26);
this.txtStockNo.TabIndex = 1;
this.txtStockNo.CharacterCasing =
System.Windows.Forms.CharacterCasing.Upper;
//
// lblMake
//
this.lblMake.AutoSize = true;
this.lblMake.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblMake.ForeColor = System.Drawing.Color.White;
this.lblMake.Location = new System.Drawing.Point(12, 61);
this.lblMake.Name = "lblMake";
this.lblMake.Size = new System.Drawing.Size(52, 20);
this.lblMake.TabIndex = 2;
this.lblMake.Text = "Make";
//
// txtMake
//
this.txtMake.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F);
this.txtMake.Location = new System.Drawing.Point(16, 84);
this.txtMake.Name = "txtMake";
this.txtMake.Size = new System.Drawing.Size(360, 26);
this.txtMake.TabIndex = 3;
this.txtMake.CharacterCasing =
System.Windows.Forms.CharacterCasing.Upper;
//
// lblModel
//
this.lblModel.AutoSize = true;
this.lblModel.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblModel.ForeColor = System.Drawing.Color.White;
this.lblModel.Location = new System.Drawing.Point(12, 113);
this.lblModel.Name = "lblModel";
this.lblModel.Size = new System.Drawing.Size(56, 20);
this.lblModel.TabIndex = 4;
this.lblModel.Text = "Model";
//
// txtModel
//
this.txtModel.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F);
this.txtModel.Location = new System.Drawing.Point(16, 136);
this.txtModel.Name = "txtModel";
this.txtModel.Size = new System.Drawing.Size(360, 26);
this.txtModel.TabIndex = 5;
this.txtModel.CharacterCasing =
System.Windows.Forms.CharacterCasing.Upper;
//
// lblReason
//
this.lblReason.AutoSize = true;
this.lblReason.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblReason.ForeColor = System.Drawing.Color.White;
this.lblReason.Location = new System.Drawing.Point(12, 165);
this.lblReason.Name = "lblReason";
this.lblReason.Size = new System.Drawing.Size(69, 20);
this.lblReason.TabIndex = 6;
this.lblReason.Text = "Reason";
//
// cmbReason
//
this.cmbReason.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F);
this.cmbReason.FormattingEnabled = true;
this.cmbReason.Location = new System.Drawing.Point(16, 188);
this.cmbReason.Name = "cmbReason";
this.cmbReason.Size = new System.Drawing.Size(360, 28);
this.cmbReason.TabIndex = 7;
//
// lblManagerCode
//
this.lblManagerCode.AutoSize = true;
this.lblManagerCode.Font = new System.Drawing.Font("Microsoft Sans
Serif", 12F, System.Drawing.FontStyle.Bold);
this.lblManagerCode.ForeColor = System.Drawing.Color.White;
this.lblManagerCode.Location = new System.Drawing.Point(12, 219);
this.lblManagerCode.Name = "lblManagerCode";
this.lblManagerCode.Size = new System.Drawing.Size(129, 20);
this.lblManagerCode.TabIndex = 10;
this.lblManagerCode.Text = "Manager Code";
//
// txtManagerCode
//
this.txtManagerCode.Font = new System.Drawing.Font("Microsoft Sans
Serif", 12F);
this.txtManagerCode.Location = new System.Drawing.Point(16, 242);
this.txtManagerCode.Name = "txtManagerCode";
this.txtManagerCode.Size = new System.Drawing.Size(360, 26);
this.txtManagerCode.TabIndex = 11;
this.txtManagerCode.CharacterCasing =
System.Windows.Forms.CharacterCasing.Upper;
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(16, 274);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(150, 50);
this.btnNext.TabIndex = 8;
this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.BtnNext_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(226, 274);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(150, 50);
this.btnCancel.TabIndex = 9;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// ManualEntryForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ClientSize = new System.Drawing.Size(384, 341);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.txtManagerCode);
this.Controls.Add(this.lblManagerCode);
this.Controls.Add(this.cmbReason);
this.Controls.Add(this.lblReason);
this.Controls.Add(this.txtModel);
this.Controls.Add(this.lblModel);
this.Controls.Add(this.txtMake);
this.Controls.Add(this.lblMake);
this.Controls.Add(this.txtStockNo);
this.Controls.Add(this.lblStockNo);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ManualEntryForm";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Manual Entry";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class MVInvoiceForm : Form
{
public MVInvoiceForm(string invoicedData)
{
InitializeComponent();
lblMessage.Text = $"Has been invoiced: {invoicedData}";
}

private void btnOk_Click(object sender, EventArgs e)


{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class MVInvoiceForm
{
private System.ComponentModel.IContainer components = null;
private Label lblMessage;
private Button btnOk;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblMessage = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblMessage.ForeColor = System.Drawing.Color.White;
this.lblMessage.Location = new System.Drawing.Point(12, 9);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(100, 25);
this.lblMessage.TabIndex = 0;
this.lblMessage.Text = "Message";
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(66, 156);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 1;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// MVInvoiceForm
//
this.ClientSize = new System.Drawing.Size(408, 209);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.lblMessage);
this.Name = "MVInvoiceForm";
this.ResumeLayout(false);
this.PerformLayout();

}
}
}
using System;
using System.Windows.Forms;

namespace YourNamespace
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using OfficeOpenXml;
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class RegisterUserForm : Form
{
private ExcelPackage _package;

public RegisterUserForm()
{
InitializeComponent();
}

public void SetExcelPackage(ExcelPackage package)


{
_package = package;
}

private void btnSave_Click(object sender, EventArgs e)


{
if (string.IsNullOrWhiteSpace(txtUsername.Text) ||
string.IsNullOrWhiteSpace(txtPassword.Text))
{
MessageBox.Show("Please enter both username and password.");
return;
}

var worksheet = _package.Workbook.Worksheets["Users"];


if (worksheet == null)
{
MessageBox.Show("Users sheet not found in the Excel file.");
return;
}

int newRow = worksheet.Dimension.End.Row + 1;


for (int i = 2; i <= worksheet.Dimension.End.Row; i++)
{
if (worksheet.Cells[i, 1].Text == "")
{
newRow = i;
break;
}
}

worksheet.Cells[newRow, 1].Value = txtUsername.Text;


worksheet.Cells[newRow, 2].Value = txtPassword.Text;
worksheet.Cells[newRow, 3].Value = txtDepartment.Text;

_package.Save();
MessageBox.Show("User registered successfully.");
this.Close();
}

private void btnCancel_Click(object sender, EventArgs e)


{
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class RegisterUserForm
{
private System.ComponentModel.IContainer components = null;
private Button btnSave;
private Button btnCancel;
private TextBox txtUsername;
private TextBox txtPassword;
private TextBox txtDepartment;
private Label lblUsername;
private Label lblPassword;
private Label lblDepartment;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.btnSave = new Button();
this.btnCancel = new Button();
this.txtUsername = new TextBox();
this.txtPassword = new TextBox();
this.txtDepartment = new TextBox();
this.lblUsername = new Label();
this.lblPassword = new Label();
this.lblDepartment = new Label();
this.SuspendLayout();
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(50, 150);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(100, 30);
this.btnSave.TabIndex = 0;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(160, 150);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 30);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtUsername
//
this.txtUsername.Location = new System.Drawing.Point(100, 30);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(160, 20);
this.txtUsername.TabIndex = 2;
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(100, 60);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(160, 20);
this.txtPassword.TabIndex = 3;
this.txtPassword.UseSystemPasswordChar = true;
//
// txtDepartment
//
this.txtDepartment.Location = new System.Drawing.Point(100, 90);
this.txtDepartment.Name = "txtDepartment";
this.txtDepartment.Size = new System.Drawing.Size(160, 20);
this.txtDepartment.TabIndex = 4;
//
// lblUsername
//
this.lblUsername.AutoSize = true;
this.lblUsername.Location = new System.Drawing.Point(30, 33);
this.lblUsername.Name = "lblUsername";
this.lblUsername.Size = new System.Drawing.Size(58, 13);
this.lblUsername.TabIndex = 5;
this.lblUsername.Text = "Username:";
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Location = new System.Drawing.Point(30, 63);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(56, 13);
this.lblPassword.TabIndex = 6;
this.lblPassword.Text = "Password:";
//
// lblDepartment
//
this.lblDepartment.AutoSize = true;
this.lblDepartment.Location = new System.Drawing.Point(30, 93);
this.lblDepartment.Name = "lblDepartment";
this.lblDepartment.Size = new System.Drawing.Size(68, 13);
this.lblDepartment.TabIndex = 7;
this.lblDepartment.Text = "Department:";
//
// RegisterUserForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 201);
this.Controls.Add(this.lblDepartment);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.lblUsername);
this.Controls.Add(this.txtDepartment);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUsername);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnSave);
this.Name = "RegisterUserForm";
this.Text = "Register User";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class StockListForm : Form
{
public StockListForm(string valetedData)
{
InitializeComponent();
lblMessage.Text = $"Has been valeted: {valetedData}";
}

private void btnOk_Click(object sender, EventArgs e)


{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class StockListForm
{
private System.ComponentModel.IContainer components = null;
private Label lblMessage;
private Button btnOk;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblMessage = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblMessage.ForeColor = System.Drawing.Color.White;
this.lblMessage.Location = new System.Drawing.Point(12, 9);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(100, 25);
this.lblMessage.TabIndex = 0;
this.lblMessage.Text = "Message";
//
// btnOk
//
this.btnOk.Location = new System.Drawing.Point(136, 114);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 1;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// StockListForm
//
this.ClientSize = new System.Drawing.Size(373, 176);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.lblMessage);
this.Name = "StockListForm";
this.ResumeLayout(false);
this.PerformLayout();

}
}
}
using OfficeOpenXml;
using System;
using System.Data;
using System.IO;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class UpdateDocumentsForm : Form
{
private ExcelPackage _package;

public UpdateDocumentsForm()
{
InitializeComponent();
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
}

private void btnUpdate_Click(object sender, EventArgs e)


{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx;*.xlsm",
Title = "Select an Excel File"
};

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
FileInfo fileInfo = new FileInfo(filePath);
_package = new ExcelPackage(fileInfo);
var worksheet = _package.Workbook.Worksheets["StockList"];
if (worksheet == null)
{
MessageBox.Show("StockList sheet not found in the Excel
file.");
return;
}

((MainForm)this.Owner).SetExcelPackage(_package);
MessageBox.Show("StockList loaded successfully.");
this.Close();
}
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class UpdateDocumentsForm
{
private System.ComponentModel.IContainer components = null;
private Button btnUpdate;
private FlowLayoutPanel flowLayoutPanelButtons;
private DataGridView dataGridView;
private TableLayoutPanel tableLayoutPanel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.btnUpdate = new Button();
this.flowLayoutPanelButtons = new FlowLayoutPanel();
this.dataGridView = new DataGridView();
this.tableLayoutPanel = new TableLayoutPanel();
this.SuspendLayout();

// tableLayoutPanel
this.tableLayoutPanel.ColumnCount = 1;
this.tableLayoutPanel.ColumnStyles.Add(new
ColumnStyle(SizeType.Percent, 100F));
this.tableLayoutPanel.RowCount = 3;
this.tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute,
40F));
this.tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute,
60F));
this.tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent,
100F));
this.tableLayoutPanel.Controls.Add(this.btnUpdate, 0, 0);
this.tableLayoutPanel.Controls.Add(this.flowLayoutPanelButtons, 0, 1);
this.tableLayoutPanel.Controls.Add(this.dataGridView, 0, 2);
this.tableLayoutPanel.Dock = DockStyle.Fill;
this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel.Name = "tableLayoutPanel";
this.tableLayoutPanel.Size = new System.Drawing.Size(800, 450);
this.tableLayoutPanel.TabIndex = 0;

// btnUpdate
this.btnUpdate.Location = new System.Drawing.Point(3, 3);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(75, 23);
this.btnUpdate.TabIndex = 0;
this.btnUpdate.Text = "Update";
this.btnUpdate.UseVisualStyleBackColor = true;
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);

// flowLayoutPanelButtons
this.flowLayoutPanelButtons.Dock = DockStyle.Fill;
this.flowLayoutPanelButtons.Location = new System.Drawing.Point(3, 43);
this.flowLayoutPanelButtons.Name = "flowLayoutPanelButtons";
this.flowLayoutPanelButtons.Size = new System.Drawing.Size(794, 54);
this.flowLayoutPanelButtons.TabIndex = 1;

// dataGridView
this.dataGridView.Dock = DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(3, 103);
this.dataGridView.Name = "dataGridView";
this.dataGridView.Size = new System.Drawing.Size(794, 344);
this.dataGridView.TabIndex = 2;

// UpdateDocumentsForm
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.tableLayoutPanel);
this.Name = "UpdateDocumentsForm";
this.Text = "Update Documents";
this.ResumeLayout(false);
}
}
}
using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OfficeOpenXml;

namespace YourNamespace
{
public partial class UserSettingsForm : Form
{
private ExcelPackage _package;
private DataTable _usersTable;

public UserSettingsForm()
{
InitializeComponent();
}

public void SetExcelPackage(ExcelPackage package)


{
_package = package;
LoadUsersTable();
PopulateUserComboBox();
}

private void LoadUsersTable()


{
var worksheet = _package.Workbook.Worksheets["Users"];
if (worksheet == null)
{
MessageBox.Show("Users sheet not found in the Excel file.");
return;
}

_usersTable = new DataTable();


foreach (var firstRowCell in worksheet.Cells[1, 1, 1,
worksheet.Dimension.End.Column])
{
_usersTable.Columns.Add(firstRowCell.Text);
}

for (var rowNumber = 2; rowNumber <= worksheet.Dimension.End.Row;


rowNumber++)
{
var row = worksheet.Cells[rowNumber, 1, rowNumber,
worksheet.Dimension.End.Column];
var newRow = _usersTable.NewRow();

foreach (var cell in row)


{
newRow[cell.Start.Column - 1] = cell.Text;
}
_usersTable.Rows.Add(newRow);
}
}

private void PopulateUserComboBox()


{
cmbUsers.Items.Clear();
foreach (DataRow row in _usersTable.Rows)
{
cmbUsers.Items.Add(row["Username"]);
}
}

private void cmbUsers_SelectedIndexChanged(object sender, EventArgs e)


{
var selectedUser = cmbUsers.SelectedItem.ToString();
var userRow = _usersTable.AsEnumerable().FirstOrDefault(row =>
row.Field<string>("Username") == selectedUser);

if (userRow != null)
{
chkManagement.Checked =
userRow["Permissions"].ToString().Contains("Management");
chkDeliveryList.Checked =
userRow["Permissions"].ToString().Contains("DeliveryList");
chkValeting.Checked =
userRow["Permissions"].ToString().Contains("Valeting");
chkUpdateDocuments.Checked =
userRow["Permissions"].ToString().Contains("UpdateDocuments");
chkWilliams.Checked =
userRow["Permissions"].ToString().Contains("Williams");
chkService.Checked =
userRow["Permissions"].ToString().Contains("Service");
chkBodyshop.Checked =
userRow["Permissions"].ToString().Contains("Bodyshop");
chkSelect.Checked =
userRow["Permissions"].ToString().Contains("Select");
chkAddSoldCar.Checked =
userRow["Permissions"].ToString().Contains("AddSoldCar");
chkSaveList.Checked =
userRow["Permissions"].ToString().Contains("SaveList");
chkRemoveCar.Checked =
userRow["Permissions"].ToString().Contains("RemoveCar");
}
}

private void btnRemoveUser_Click(object sender, EventArgs e)


{
var selectedUser = cmbUsers.SelectedItem.ToString();
var userRow = _usersTable.AsEnumerable().FirstOrDefault(row =>
row.Field<string>("Username") == selectedUser);
if (userRow != null)
{
_usersTable.Rows.Remove(userRow);
PopulateUserComboBox();
SaveUsersTable();
MessageBox.Show("User removed successfully.");
}
}

private void btnSave_Click(object sender, EventArgs e)


{
var selectedUser = cmbUsers.SelectedItem?.ToString();
if (string.IsNullOrEmpty(selectedUser))
{
MessageBox.Show("Please select a user.");
return;
}

var userRow = _usersTable.AsEnumerable().FirstOrDefault(row =>


row.Field<string>("Username") == selectedUser);
if (userRow == null)
{
MessageBox.Show("Selected user not found.");
return;
}

var permissions = new StringBuilder();


if (chkManagement.Checked) permissions.Append("Management;");
if (chkDeliveryList.Checked) permissions.Append("DeliveryList;");
if (chkValeting.Checked) permissions.Append("Valeting;");
if (chkUpdateDocuments.Checked) permissions.Append("UpdateDocuments;");
if (chkWilliams.Checked) permissions.Append("Williams;");
if (chkService.Checked) permissions.Append("Service;");
if (chkBodyshop.Checked) permissions.Append("Bodyshop;");
if (chkSelect.Checked) permissions.Append("Select;");
if (chkAddSoldCar.Checked) permissions.Append("AddSoldCar;");
if (chkSaveList.Checked) permissions.Append("SaveList;");
if (chkRemoveCar.Checked) permissions.Append("RemoveCar;");

userRow["Permissions"] = permissions.ToString();

SaveUsersTable();
MessageBox.Show("User settings saved successfully.");
}

private void SaveUsersTable()


{
var worksheet = _package.Workbook.Worksheets["Users"];
if (worksheet == null)
{
MessageBox.Show("Users sheet not found in the Excel file.");
return;
}

worksheet.DeleteRow(2, worksheet.Dimension.End.Row - 1);

for (int rowIndex = 0; rowIndex < _usersTable.Rows.Count; rowIndex++)


{
var row = _usersTable.Rows[rowIndex];
for (int colIndex = 0; colIndex < _usersTable.Columns.Count;
colIndex++)
{
worksheet.Cells[rowIndex + 2, colIndex + 1].Value =
row[colIndex];
}
}

_package.Save();
}

private void btnCancel_Click(object sender, EventArgs e)


{
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class UserSettingsForm
{
private System.ComponentModel.IContainer components = null;
private Button btnRemoveUser;
private Button btnSave;
private Button btnCancel;
private ComboBox cmbUsers;
private CheckBox chkManagement;
private CheckBox chkDeliveryList;
private CheckBox chkValeting;
private CheckBox chkUpdateDocuments;
private CheckBox chkWilliams;
private CheckBox chkService;
private CheckBox chkBodyshop;
private CheckBox chkSelect;
private CheckBox chkAddSoldCar;
private CheckBox chkSaveList;
private CheckBox chkRemoveCar; // Adăugăm checkbox-ul pentru Remove Car
private Label lblSelectUser;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.btnRemoveUser = new Button();
this.btnSave = new Button();
this.btnCancel = new Button();
this.cmbUsers = new ComboBox();
this.chkManagement = new CheckBox();
this.chkDeliveryList = new CheckBox();
this.chkValeting = new CheckBox();
this.chkUpdateDocuments = new CheckBox();
this.chkWilliams = new CheckBox();
this.chkService = new CheckBox();
this.chkBodyshop = new CheckBox();
this.chkSelect = new CheckBox();
this.chkAddSoldCar = new CheckBox();
this.chkSaveList = new CheckBox();
this.chkRemoveCar = new CheckBox(); // Adăugăm checkbox-ul pentru
Remove Car
this.lblSelectUser = new Label();
this.SuspendLayout();
//
// btnRemoveUser
//
this.btnRemoveUser.Location = new System.Drawing.Point(160, 150);
this.btnRemoveUser.Name = "btnRemoveUser";
this.btnRemoveUser.Size = new System.Drawing.Size(100, 30);
this.btnRemoveUser.TabIndex = 1;
this.btnRemoveUser.Text = "Remove User";
this.btnRemoveUser.UseVisualStyleBackColor = true;
this.btnRemoveUser.Click += new
System.EventHandler(this.btnRemoveUser_Click);
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(50, 350);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(100, 30);
this.btnSave.TabIndex = 2;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(160, 350);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 30);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// cmbUsers
//
this.cmbUsers.DropDownStyle = ComboBoxStyle.DropDownList;
this.cmbUsers.FormattingEnabled = true;
this.cmbUsers.Location = new System.Drawing.Point(100, 30);
this.cmbUsers.Name = "cmbUsers";
this.cmbUsers.Size = new System.Drawing.Size(160, 21);
this.cmbUsers.TabIndex = 4;
this.cmbUsers.SelectedIndexChanged += new
System.EventHandler(this.cmbUsers_SelectedIndexChanged);
//
// chkManagement
//
this.chkManagement.AutoSize = true;
this.chkManagement.Location = new System.Drawing.Point(50, 90);
this.chkManagement.Name = "chkManagement";
this.chkManagement.Size = new System.Drawing.Size(88, 17);
this.chkManagement.TabIndex = 6;
this.chkManagement.Text = "Management";
this.chkManagement.UseVisualStyleBackColor = true;
//
// chkDeliveryList
//
this.chkDeliveryList.AutoSize = true;
this.chkDeliveryList.Location = new System.Drawing.Point(50, 110);
this.chkDeliveryList.Name = "chkDeliveryList";
this.chkDeliveryList.Size = new System.Drawing.Size(83, 17);
this.chkDeliveryList.TabIndex = 7;
this.chkDeliveryList.Text = "Delivery List";
this.chkDeliveryList.UseVisualStyleBackColor = true;
//
// chkValeting
//
this.chkValeting.AutoSize = true;
this.chkValeting.Location = new System.Drawing.Point(160, 90);
this.chkValeting.Name = "chkValeting";
this.chkValeting.Size = new System.Drawing.Size(63, 17);
this.chkValeting.TabIndex = 8;
this.chkValeting.Text = "Valeting";
this.chkValeting.UseVisualStyleBackColor = true;
//
// chkUpdateDocuments
//
this.chkUpdateDocuments.AutoSize = true;
this.chkUpdateDocuments.Location = new System.Drawing.Point(160, 110);
this.chkUpdateDocuments.Name = "chkUpdateDocuments";
this.chkUpdateDocuments.Size = new System.Drawing.Size(115, 17);
this.chkUpdateDocuments.TabIndex = 9;
this.chkUpdateDocuments.Text = "Update Documents";
this.chkUpdateDocuments.UseVisualStyleBackColor = true;
//
// chkWilliams
//
this.chkWilliams.AutoSize = true;
this.chkWilliams.Location = new System.Drawing.Point(50, 130);
this.chkWilliams.Name = "chkWilliams";
this.chkWilliams.Size = new System.Drawing.Size(65, 17);
this.chkWilliams.TabIndex = 10;
this.chkWilliams.Text = "Williams";
this.chkWilliams.UseVisualStyleBackColor = true;
//
// chkService
//
this.chkService.AutoSize = true;
this.chkService.Location = new System.Drawing.Point(50, 150);
this.chkService.Name = "chkService";
this.chkService.Size = new System.Drawing.Size(61, 17);
this.chkService.TabIndex = 11;
this.chkService.Text = "Service";
this.chkService.UseVisualStyleBackColor = true;
//
// chkBodyshop
//
this.chkBodyshop.AutoSize = true;
this.chkBodyshop.Location = new System.Drawing.Point(50, 170);
this.chkBodyshop.Name = "chkBodyshop";
this.chkBodyshop.Size = new System.Drawing.Size(72, 17);
this.chkBodyshop.TabIndex = 12;
this.chkBodyshop.Text = "Bodyshop";
this.chkBodyshop.UseVisualStyleBackColor = true;
//
// chkSelect
//
this.chkSelect.AutoSize = true;
this.chkSelect.Location = new System.Drawing.Point(160, 130);
this.chkSelect.Name = "chkSelect";
this.chkSelect.Size = new System.Drawing.Size(55, 17);
this.chkSelect.TabIndex = 13;
this.chkSelect.Text = "Select";
this.chkSelect.UseVisualStyleBackColor = true;
//
// chkAddSoldCar
//
this.chkAddSoldCar.AutoSize = true;
this.chkAddSoldCar.Location = new System.Drawing.Point(50, 190);
this.chkAddSoldCar.Name = "chkAddSoldCar";
this.chkAddSoldCar.Size = new System.Drawing.Size(86, 17);
this.chkAddSoldCar.TabIndex = 14;
this.chkAddSoldCar.Text = "Add Sold Car";
this.chkAddSoldCar.UseVisualStyleBackColor = true;
//
// chkSaveList
//
this.chkSaveList.AutoSize = true;
this.chkSaveList.Location = new System.Drawing.Point(160, 190);
this.chkSaveList.Name = "chkSaveList";
this.chkSaveList.Size = new System.Drawing.Size(70, 17);
this.chkSaveList.TabIndex = 15;
this.chkSaveList.Text = "Save List";
this.chkSaveList.UseVisualStyleBackColor = true;
//
// chkRemoveCar
//
this.chkRemoveCar.AutoSize = true;
this.chkRemoveCar.Location = new System.Drawing.Point(50, 210);
this.chkRemoveCar.Name = "chkRemoveCar";
this.chkRemoveCar.Size = new System.Drawing.Size(85, 17);
this.chkRemoveCar.TabIndex = 16;
this.chkRemoveCar.Text = "Remove Car";
this.chkRemoveCar.UseVisualStyleBackColor = true;
//
// lblSelectUser
//
this.lblSelectUser.AutoSize = true;
this.lblSelectUser.Location = new System.Drawing.Point(30, 33);
this.lblSelectUser.Name = "lblSelectUser";
this.lblSelectUser.Size = new System.Drawing.Size(64, 13);
this.lblSelectUser.TabIndex = 10;
this.lblSelectUser.Text = "Select User:";
//
// UserSettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 400);
this.Controls.Add(this.chkRemoveCar); // Adăugăm checkbox-ul pentru
Remove Car
this.Controls.Add(this.chkAddSoldCar);
this.Controls.Add(this.chkSaveList);
this.Controls.Add(this.lblSelectUser);
this.Controls.Add(this.chkSelect);
this.Controls.Add(this.chkBodyshop);
this.Controls.Add(this.chkService);
this.Controls.Add(this.chkWilliams);
this.Controls.Add(this.chkUpdateDocuments);
this.Controls.Add(this.chkValeting);
this.Controls.Add(this.chkDeliveryList);
this.Controls.Add(this.chkManagement);
this.Controls.Add(this.cmbUsers);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnRemoveUser);
this.Name = "UserSettingsForm";
this.Text = "User Settings";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class ValetingDetailsForm : Form
{
private ExcelPackage package;
private string registrationNumber;
private List<Button> selectedButtons = new List<Button>();

public ValetingDetailsForm(ExcelPackage package, string registrationNumber)


{
InitializeComponent();
this.package = package;
this.registrationNumber = registrationNumber;
LoadValeters();
}

private void LoadValeters()


{
var sheet = package.Workbook.Worksheets["Valeters"];
var valeters = new List<string>();
for (int row = 2; row <= sheet.Dimension.End.Row; row++)
{
valeters.Add(sheet.Cells[row, 1].Text);
}

cmbValeters.DataSource = valeters;
}

private void BtnService_Click(object sender, EventArgs e)


{
var button = sender as Button;

if (selectedButtons.Contains(button))
{
selectedButtons.Remove(button);
button.BackColor = SystemColors.Control;
button.ForeColor = SystemColors.ControlText;
}
else
{
if (selectedButtons.Count < 2 && (selectedButtons.Count == 0 ||
selectedButtons[0].Text == "Williams" || button.Text == "Williams"))
{
selectedButtons.Add(button);
button.BackColor = Color.Orange;
button.ForeColor = Color.White;
}
else
{
MessageBox.Show("You can select a maximum of two services,
including Williams.", "Limit Reached", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}

private void BtnFinish_Click(object sender, EventArgs e)


{
// Implement your submission logic here
MessageBox.Show("Finish clicked.");
}

private void BtnCancel_Click(object sender, EventArgs e)


{
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ValetingDetailsForm
{
private System.ComponentModel.IContainer components = null;
private Label lblValeters;
private ComboBox cmbValeters;
private Button btnFvCar;
private Button btnFvVan;
private Button btnWilliams;
private Button btnReclean;
private Button btnRecleanService;
private Button btnRecleanFOC;
private Button btnFinish;
private Button btnCancel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblValeters = new System.Windows.Forms.Label();
this.cmbValeters = new System.Windows.Forms.ComboBox();
this.btnFvCar = new System.Windows.Forms.Button();
this.btnFvVan = new System.Windows.Forms.Button();
this.btnWilliams = new System.Windows.Forms.Button();
this.btnReclean = new System.Windows.Forms.Button();
this.btnRecleanService = new System.Windows.Forms.Button();
this.btnRecleanFOC = new System.Windows.Forms.Button();
this.btnFinish = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblValeters
//
this.lblValeters.AutoSize = true;
this.lblValeters.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F, System.Drawing.FontStyle.Bold);
this.lblValeters.ForeColor = System.Drawing.Color.White;
this.lblValeters.Location = new System.Drawing.Point(12, 9);
this.lblValeters.Name = "lblValeters";
this.lblValeters.Size = new System.Drawing.Size(75, 20);
this.lblValeters.TabIndex = 0;
this.lblValeters.Text = "Valeters";
//
// cmbValeters
//
this.cmbValeters.Font = new System.Drawing.Font("Microsoft Sans Serif",
12F);
this.cmbValeters.FormattingEnabled = true;
this.cmbValeters.Location = new System.Drawing.Point(16, 32);
this.cmbValeters.Name = "cmbValeters";
this.cmbValeters.Size = new System.Drawing.Size(360, 28);
this.cmbValeters.TabIndex = 1;
//
// btnFvCar
//
this.btnFvCar.Location = new System.Drawing.Point(16, 66);
this.btnFvCar.Name = "btnFvCar";
this.btnFvCar.Size = new System.Drawing.Size(150, 50);
this.btnFvCar.TabIndex = 2;
this.btnFvCar.Text = "Fv Car";
this.btnFvCar.UseVisualStyleBackColor = true;
this.btnFvCar.Click += new System.EventHandler(this.BtnService_Click);
//
// btnFvVan
//
this.btnFvVan.Location = new System.Drawing.Point(226, 66);
this.btnFvVan.Name = "btnFvVan";
this.btnFvVan.Size = new System.Drawing.Size(150, 50);
this.btnFvVan.TabIndex = 3;
this.btnFvVan.Text = "Fv Van";
this.btnFvVan.UseVisualStyleBackColor = true;
this.btnFvVan.Click += new System.EventHandler(this.BtnService_Click);
//
// btnWilliams
//
this.btnWilliams.Location = new System.Drawing.Point(16, 122);
this.btnWilliams.Name = "btnWilliams";
this.btnWilliams.Size = new System.Drawing.Size(150, 50);
this.btnWilliams.TabIndex = 4;
this.btnWilliams.Text = "Williams";
this.btnWilliams.UseVisualStyleBackColor = true;
this.btnWilliams.Click += new
System.EventHandler(this.BtnService_Click);
//
// btnReclean
//
this.btnReclean.Location = new System.Drawing.Point(226, 122);
this.btnReclean.Name = "btnReclean";
this.btnReclean.Size = new System.Drawing.Size(150, 50);
this.btnReclean.TabIndex = 5;
this.btnReclean.Text = "Re-clean";
this.btnReclean.UseVisualStyleBackColor = true;
this.btnReclean.Click += new
System.EventHandler(this.BtnService_Click);
//
// btnRecleanService
//
this.btnRecleanService.Location = new System.Drawing.Point(16, 178);
this.btnRecleanService.Name = "btnRecleanService";
this.btnRecleanService.Size = new System.Drawing.Size(150, 50);
this.btnRecleanService.TabIndex = 6;
this.btnRecleanService.Text = "Re-clean(Service)";
this.btnRecleanService.UseVisualStyleBackColor = true;
this.btnRecleanService.Click += new
System.EventHandler(this.BtnService_Click);
//
// btnRecleanFOC
//
this.btnRecleanFOC.Location = new System.Drawing.Point(226, 178);
this.btnRecleanFOC.Name = "btnRecleanFOC";
this.btnRecleanFOC.Size = new System.Drawing.Size(150, 50);
this.btnRecleanFOC.TabIndex = 7;
this.btnRecleanFOC.Text = "Re-clean(F.O.C)";
this.btnRecleanFOC.UseVisualStyleBackColor = true;
this.btnRecleanFOC.Click += new
System.EventHandler(this.BtnService_Click);
//
// btnFinish
//
this.btnFinish.Location = new System.Drawing.Point(16, 234);
this.btnFinish.Name = "btnFinish";
this.btnFinish.Size = new System.Drawing.Size(150, 50);
this.btnFinish.TabIndex = 8;
this.btnFinish.Text = "Finish";
this.btnFinish.UseVisualStyleBackColor = true;
this.btnFinish.Click += new System.EventHandler(this.BtnFinish_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(226, 234);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(150, 50);
this.btnCancel.TabIndex = 9;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// ValetingDetailsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ClientSize = new System.Drawing.Size(384, 301);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnFinish);
this.Controls.Add(this.btnRecleanFOC);
this.Controls.Add(this.btnRecleanService);
this.Controls.Add(this.btnReclean);
this.Controls.Add(this.btnWilliams);
this.Controls.Add(this.btnFvVan);
this.Controls.Add(this.btnFvCar);
this.Controls.Add(this.cmbValeters);
this.Controls.Add(this.lblValeters);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ValetingDetailsForm";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Valeting Details";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using OfficeOpenXml;
using System;
using System.Windows.Forms;

namespace YourNamespace
{
public partial class ValetingForm : Form
{
private ExcelPackage package;

public ValetingForm(ExcelPackage package)


{
InitializeComponent();
this.package = package;
}

private void BtnNext_Click(object sender, EventArgs e)


{
string regNumber = txtRegNo.Text.Trim();

if (string.IsNullOrEmpty(regNumber))
{
MessageBox.Show("Please enter a registration number.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

var stockListSheet = package.Workbook.Worksheets["StockList"];


var mvInvoiceSheet = package.Workbook.Worksheets["MVinvoice"];
bool stockListFound = false;
bool mvInvoiceFound = false;
string stockListData = null;
string mvInvoiceData = null;

// Check StockList sheet


for (int row = 2; row <= stockListSheet.Dimension.End.Row; row++)
{
if (stockListSheet.Cells[row, 3].Text.Equals(regNumber,
StringComparison.OrdinalIgnoreCase))
{
stockListFound = true;
stockListData = stockListSheet.Cells[row, 9].Text;
break;
}
}

// Check MVinvoice sheet


for (int row = 2; row <= mvInvoiceSheet.Dimension.End.Row; row++)
{
if (mvInvoiceSheet.Cells[row, 4].Text.Equals(regNumber,
StringComparison.OrdinalIgnoreCase))
{
mvInvoiceFound = true;
mvInvoiceData = mvInvoiceSheet.Cells[row, 8].Text;
break;
}
}

if (stockListFound && !string.IsNullOrEmpty(stockListData) ||


mvInvoiceFound)
{
var managerCodeForm = new ManagerCodeForm(package, stockListData,
mvInvoiceData);
if (managerCodeForm.ShowDialog() == DialogResult.OK)
{
ProceedToNextStep(regNumber);
}
}
else
{
ProceedToNextStep(regNumber);
}
}

private void ProceedToNextStep(string regNumber)


{
var valetingDetailsForm = new ValetingDetailsForm(package, regNumber);
valetingDetailsForm.ShowDialog();
}

private void BtnCancel_Click(object sender, EventArgs e)


{
this.Close();
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ValetingForm
{
private System.ComponentModel.IContainer components = null;
private Label lblMessage;
private TextBox txtRegNo;
private Button btnNext;
private Button btnCancel;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblMessage = new Label();
this.txtRegNo = new TextBox();
this.btnNext = new Button();
this.btnCancel = new Button();
this.SuspendLayout();
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif",
14F, System.Drawing.FontStyle.Bold);
this.lblMessage.ForeColor = System.Drawing.Color.White;
this.lblMessage.Location = new System.Drawing.Point(12, 9);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(241, 24);
this.lblMessage.TabIndex = 0;
this.lblMessage.Text = "Enter Registration Number";
//
// txtRegNo
//
this.txtRegNo.Font = new System.Drawing.Font("Microsoft Sans Serif",
24F);
this.txtRegNo.Location = new System.Drawing.Point(12, 36);
this.txtRegNo.Name = "txtRegNo";
this.txtRegNo.Size = new System.Drawing.Size(360, 44);
this.txtRegNo.TabIndex = 1;
this.txtRegNo.CharacterCasing =
System.Windows.Forms.CharacterCasing.Upper;
this.txtRegNo.TextAlign =
System.Windows.Forms.HorizontalAlignment.Center;
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(12, 86);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(150, 50);
this.btnNext.TabIndex = 2;
this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.BtnNext_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(222, 86);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(150, 50);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// ValetingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ClientSize = new System.Drawing.Size(384, 161);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.txtRegNo);
this.Controls.Add(this.lblMessage);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ValetingForm";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Valeting";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
using System;
using System.Linq;
using System.Windows.Forms;
using OfficeOpenXml;
namespace YourNamespace
{
public partial class ValetingProgressForm : Form
{
private ExcelPackage _package;

public ValetingProgressForm(ExcelPackage package)


{
InitializeComponent();
_package = package;
ApplyDarkTheme();
LoadProgressData();
}

private void LoadProgressData()


{
var worksheet = _package.Workbook.Worksheets["StockList"];
if (worksheet == null)
{
MessageBox.Show("StockList sheet not found in the Excel file.");
return;
}

int totalVehicles = worksheet.Dimension.End.Row - 1;


int readyVehicles = 0;

for (int row = 2; row <= worksheet.Dimension.End.Row; row++)


{
if (!string.IsNullOrWhiteSpace(worksheet.Cells[row, 9].Text))
{
readyVehicles++;
}
}

int remainingVehicles = totalVehicles - readyVehicles;


double percentageReady = (double)readyVehicles / totalVehicles * 100;

lblTotalVehicles.Text = $"Total Vehicles: {totalVehicles}";


lblReadyVehicles.Text = $"Ready Vehicles: {readyVehicles}
({percentageReady:F2}%)";
lblRemainingVehicles.Text = $"Remaining Vehicles: {remainingVehicles}";
}

private void ApplyDarkTheme()


{
this.BackColor = System.Drawing.Color.FromArgb(45, 45, 48);
this.ForeColor = System.Drawing.Color.White;

foreach (Control control in this.Controls)


{
ApplyThemeToControl(control);
}
}

private void ApplyThemeToControl(Control control)


{
switch (control)
{
case Button button:
button.BackColor = System.Drawing.Color.FromArgb(28, 28, 28);
button.ForeColor = System.Drawing.Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
break;
case TextBox textBox:
textBox.BackColor = System.Drawing.Color.FromArgb(30, 30, 30);
textBox.ForeColor = System.Drawing.Color.White;
break;
case Label label:
label.ForeColor = System.Drawing.Color.White;
break;
}

foreach (Control child in control.Controls)


{
ApplyThemeToControl(child);
}
}
}
}
using System.Windows.Forms;

namespace YourNamespace
{
partial class ValetingProgressForm
{
private System.ComponentModel.IContainer components = null;
private Label lblTotalVehicles;
private Label lblReadyVehicles;
private Label lblRemainingVehicles;

protected override void Dispose(bool disposing)


{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()


{
this.lblTotalVehicles = new Label();
this.lblReadyVehicles = new Label();
this.lblRemainingVehicles = new Label();
this.SuspendLayout();
//
// lblTotalVehicles
//
this.lblTotalVehicles.AutoSize = true;
this.lblTotalVehicles.Location = new System.Drawing.Point(12, 20);
this.lblTotalVehicles.Name = "lblTotalVehicles";
this.lblTotalVehicles.Size = new System.Drawing.Size(77, 13);
this.lblTotalVehicles.TabIndex = 0;
this.lblTotalVehicles.Text = "Total Vehicles:";
//
// lblReadyVehicles
//
this.lblReadyVehicles.AutoSize = true;
this.lblReadyVehicles.Location = new System.Drawing.Point(12, 50);
this.lblReadyVehicles.Name = "lblReadyVehicles";
this.lblReadyVehicles.Size = new System.Drawing.Size(85, 13);
this.lblReadyVehicles.TabIndex = 1;
this.lblReadyVehicles.Text = "Ready Vehicles:";
//
// lblRemainingVehicles
//
this.lblRemainingVehicles.AutoSize = true;
this.lblRemainingVehicles.Location = new System.Drawing.Point(12, 80);
this.lblRemainingVehicles.Name = "lblRemainingVehicles";
this.lblRemainingVehicles.Size = new System.Drawing.Size(103, 13);
this.lblRemainingVehicles.TabIndex = 2;
this.lblRemainingVehicles.Text = "Remaining Vehicles:";
//
// ValetingProgressForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 120);
this.Controls.Add(this.lblRemainingVehicles);
this.Controls.Add(this.lblReadyVehicles);
this.Controls.Add(this.lblTotalVehicles);
this.Name = "ValetingProgressForm";
this.Text = "Valeting Progress";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}

You might also like