示例#1
0
 /// <summary>
 /// Prepares an empty form
 /// </summary>
 /// <param name="clients">The clients table</param>
 /// <param name="selectQueryString">The select statement used for the command builder</param>
 public frmClient(SQLiteInstance db, DataTable clients, string selectQueryString, DataRowView identity = null)
 {
     InitializeComponent();
     Db                = db;
     Clients           = clients;
     NewClient         = true;
     SelectQueryString = selectQueryString;
     if (identity != null)
     {
         txtRate.Text = identity.Row["hourly_rate"].ToString();
     }
 }
示例#2
0
        private void NewTimesheet_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileBrowser = new SaveFileDialog();

            fileBrowser.CheckFileExists = false;
            fileBrowser.CheckPathExists = false;
            fileBrowser.DefaultExt      = "sqlite";

            if (fileBrowser.ShowDialog() == DialogResult.OK)
            {
                timesheet = new SQLiteInstance(fileBrowser.FileName, createQueries);
                EnableTimesheet();
            }
        }
示例#3
0
        /// <summary>
        /// Prepares a form with provided client information
        /// </summary>
        /// <param name="db">The clients table</param>
        /// <param name="clients"></param>
        /// <param name="row">The row from the databse</param>
        /// <param name="selectQueryString"></param>
        public frmClient(SQLiteInstance db, DataTable clients, DataRowView row, string selectQueryString)
        {
            InitializeComponent();
            Db      = db;
            Clients = clients;

            // For some reason its created as an Int64 so it needs to be converted to an Int32
            ClientId        = Convert.ToInt32(row["id"]);
            txtName.Text    = row["name"].ToString();
            txtAddress.Text = row["address"].ToString();
            txtPhone.Text   = row["phone"].ToString();
            txtEmail.Text   = row["email"].ToString();
            txtRate.Text    = row["hourly_rate"].ToString();

            SelectQueryString = selectQueryString;
        }
示例#4
0
        private void DisableTimesheet()
        {
            if (timesheet != null)
            {
                dgvTimesheet.DataSource = null;
                source    = null;
                timesheet = null;
            }

            mnuTimesheetClose.Enabled = false;
            btnTaskToggle.Enabled     = false;
            txtTaskName.Enabled       = false;
            lblTaskName.Enabled       = false;
            dgvTimesheet.Enabled      = false;
            btnTaskSave.Enabled       = false;
            btnTaskClear.Enabled      = false;
            txtTaskName.Text          = string.Empty;
            setTimerText(0);
        }
示例#5
0
        public frmInvoice(SQLiteInstance db, DataGridViewSelectedRowCollection dgTasks)
        {
            InitializeComponent();

            this.Db = db;

            btnClientEdit.Enabled   = false;
            btnClientDelete.Enabled = false;
            btnClientNew.Enabled    = true;

            btnIdentityEdit.Enabled   = false;
            btnIdentityDelete.Enabled = false;
            btnIdentityNew.Enabled    = true;

            cbClient.SelectedIndexChanged   += CbClient_SelectedIndexChanged;
            cbIdentity.SelectedIndexChanged += CbIdentity_SelectedIndexChanged;

            GetIdentities();
            GetClients();

            // Keep a synchronized list of tasks with extended properties between the datagrid view and database
            foreach (DataGridViewRow dgTask in dgTasks)
            {
                Task temporaryTask = new Task();

                temporaryTask.Id          = (Int64)dgTask.Cells["id"].Value;
                temporaryTask.Description = dgTask.Cells["description"].Value.ToString();
                temporaryTask.BeginDate   = DateTime.Parse(dgTask.Cells["begindate"].Value.ToString());
                temporaryTask.EndDate     = DateTime.Parse(dgTask.Cells["enddate"].Value.ToString());

                // add to task list
                Tasks.Add(temporaryTask);
            }

            dgvInvoice.DataSource = Tasks;
        }
示例#6
0
        private void OpenTimesheet_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileBrowser = new OpenFileDialog()
            {
                CheckFileExists = false,
                CheckPathExists = false,
                DefaultExt      = "sqlite",
                Multiselect     = false
            };

            DialogResult result = fileBrowser.ShowDialog();

            if (result.Equals(DialogResult.OK) && isSQLiteDatabase(fileBrowser.FileName))
            {
                DisableTimesheet();
                timesheet = new SQLiteInstance(fileBrowser.FileName, createQueries);

                EnableTimesheet();
            }
            else if (result != DialogResult.Cancel)
            {
                MessageBox.Show("The file you tried to open was not a SQLite Database.");
            }
        }