Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (NewClient)
            {
                // clone a new row schema from client table
                Client = Clients.NewRow();

                Client["name"]    = txtName.Text;
                Client["address"] = txtAddress.Text;
                Client["phone"]   = txtPhone.Text;
                Client["email"]   = txtEmail.Text;

                Clients.Rows.Add(Client);
                Db.Commit(Clients, SelectQueryString);
            }
            else
            {
                // find existing client in clients table
                Client = Clients.Rows.Find(ClientId);

                Client["name"]    = txtName.Text;
                Client["address"] = txtAddress.Text;
                Client["phone"]   = txtPhone.Text;
                Client["email"]   = txtEmail.Text;

                Db.Commit(Clients, SelectQueryString);
            }
            Close();
        }
Example #2
0
 /// <summary>
 /// When an identity is deleted from the form:
 ///     Delete row from table
 ///     Commit changes to database
 ///     Repopulate identities table
 /// </summary>
 private void btnIdentityDelete_Click(object sender, EventArgs e)
 {
     if (cbIdentity.SelectedIndex > -1)
     {
         Identities.Rows.Find(((DataRowView)cbIdentity.SelectedValue)["id"]).Delete();
         Db.Commit(Identities, QueryString.Identity.Select);
         GetIdentities();
     }
 }
Example #3
0
        private void DgvTimesheet_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                EditMaster editor = null;

                string columnName = dgvTimesheet.Columns[e.ColumnIndex].Name;

                DataGridViewRow row = dgvTimesheet.Rows[e.RowIndex];

                if (columnName == "description")
                {
                    editor = new EditDescription(row.Cells[e.ColumnIndex].Value.ToString());

                    if (editor.ShowDialog() == DialogResult.OK)
                    {
                        _table.Rows.Find(row.Cells["id"].Value)["description"] = ((EditDescription)editor).getValue();

                        timesheet.Commit(_table, QueryString.Task.Select);
                    }
                }
                else if (columnName == "duration")
                {
                    editor = new EditTime(DateTime.Parse(_table.Rows.Find(row.Cells["id"].Value)["enddate"].ToString()).Subtract(DateTime.Parse(_table.Rows.Find(row.Cells["id"].Value)["begindate"].ToString())));

                    if (editor.ShowDialog() == DialogResult.OK)
                    {
                        _table.Rows[e.RowIndex]["enddate"] = DateTime.Parse(_table.Rows.Find(row.Cells["id"].Value)["begindate"].ToString()).Add(TimeSpan.Parse(((EditTime)editor).getValue().ToString()));

                        timesheet.Commit(_table, QueryString.Task.Select);

                        refreshTaskValues(dgvTimesheet.Rows[e.RowIndex]);
                    }
                }
            }
        }