Exemple #1
0
    private void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            if (lvwMain.SelectedIndices.Count == 0)
            {
                messageBoxOK("An entry must be selected before it can be deleted.");
                return;
            }

            if (messageBoxYesNo("Are you sure you want to delete this entry?") == DialogResult.No)
            {
                return;
            }

            clsTimeLogEntry selectedEntry = (clsTimeLogEntry)lvwMain.SelectedItems[0].Tag;

            mTimeLogList.Delete(selectedEntry);

            lvwMain.Items.Remove(lvwMain.SelectedItems[0]);
        }
        catch (Exception ex)
        {
            msgException(ex);
        }
    }
Exemple #2
0
    private void btnUpdate_Click(object sender, EventArgs e)
    {
        if (lvwMain.SelectedIndices.Count == 0)
        {
            messageBoxOK("An entry must be selected before it can be updated.");
            return;
        }

        clsTimeLogEntry selectedEntry = (clsTimeLogEntry)lvwMain.SelectedItems[0].Tag;

        frmMaintenance addUpdate = new frmMaintenance("Update", selectedEntry);

        if (addUpdate.ShowDialog() == DialogResult.OK)
        {
            int itemIndex = lvwMain.SelectedItems[0].Index;
            lvwMain.Items[itemIndex] = new ListViewItem(selectedEntry.EmployeeID);

            lvwMain.Items[itemIndex].SubItems.Add(selectedEntry.DateWorked.ToShortDateString());
            lvwMain.Items[itemIndex].SubItems.Add(selectedEntry.HoursWorked.ToString("0.00"));

            if (selectedEntry.Billable == true)
            {
                lvwMain.Items[itemIndex].SubItems.Add("Yes");
            }
            else
            {
                lvwMain.Items[itemIndex].SubItems.Add("No");
            }

            lvwMain.Items[itemIndex].SubItems.Add(selectedEntry.Description);
        }
    }
Exemple #3
0
    private void addEntryToListView(clsTimeLogEntry entry, bool ensureVisible)
    {
        ListViewItem item = new ListViewItem(entry.EmployeeID);

        item.SubItems.Add(entry.DateWorked.ToShortDateString());
        item.SubItems.Add(entry.HoursWorked.ToString("0.00"));

        if (entry.Billable == true)
        {
            item.SubItems.Add("Yes");
        }
        else
        {
            item.SubItems.Add("No");
        }

        item.SubItems.Add(entry.Description);

        item.Tag = entry;

        lvwMain.Items.Add(item);

        if (ensureVisible == true)
        {
            int index = lvwMain.Items.IndexOf(item);
            lvwMain.Items[index].EnsureVisible();
            lvwMain.Items[index].Selected = true;
        }
    }
    public static void Update(clsTimeLogEntry entry)
    {
        string action    = "update";
        string arguments = "&serializedEntry=" + entry.Serialize();
        string url       = createUrl(action, arguments);

        string responseString = getResponseString(url);

        entry.Deserialize(responseString);
    }
    public static void Delete(clsTimeLogEntry entry)
    {
        string action    = "delete";
        string arguments = "&serializedEntry=" + entry.Serialize();
        string url       = createUrl(action, arguments);

        string responseString = getResponseString(url);

        if (responseString != "ok")
        {
            throw new Exception("Unable to delete entry");
        }
    }
Exemple #6
0
    private void delete()
    {
        clsTimeLogList.UserID = Request.QueryString["userID"];

        string          serializedEntry = Request.QueryString["serializedEntry"];
        clsTimeLogEntry entry           = new clsTimeLogEntry();

        entry.Deserialize(serializedEntry);
        mTimeLogList.Delete(entry);

        string responseString = "ok";

        Response.Write(responseString);
    }
Exemple #7
0
    public List <clsTimeLogEntry> GetAllEntries(TimeLogDate beginDate, TimeLogDate endDate)
    {
        List <clsTimeLogEntry> listBetweenDates = new List <clsTimeLogEntry>();
        string sql;

        using (clsDatabase db = new clsDatabase(mConnectionString))
            using (clsQueryResults results = new clsQueryResults())
            {
                db.Open();

                sql = "SELECT COUNT(*) AS NumRecords FROM TimeLogEntries WHERE DateWorked >= "
                      + db.ToSql(beginDate)
                      + " AND DateWorked <= " + db.ToSql(endDate);

                results.Open(db, sql);
                int count = (int)results.GetColValue("NumRecords");

                if (count > 500)
                {
                    throw new clsTooManyRecordsException("More than 500 matching records found.");
                }

                results.Close();

                sql = "SELECT * FROM TimeLogEntries WHERE DateWorked >= "
                      + db.ToSql(beginDate)
                      + " AND DateWorked <=" + db.ToSql(endDate)
                      + " ORDER BY DateWorked DESC, EmployeeID, HoursWorked";

                results.Open(db, sql);

                while (results.EOF == false)
                {
                    clsTimeLogEntry entry = new clsTimeLogEntry();
                    entry.RestoreStateFromQuery(results);
                    listBetweenDates.Add(entry);
                    results.MoveNext();
                }
            }

        return(listBetweenDates);
    }
Exemple #8
0
 public void Add(clsTimeLogEntry entry)
 {
     using (clsDatabase db = new clsDatabase(mConnectionString))
     {
         try
         {
             db.Open();
             db.BeginTransaction();
             entry.Add(db, UserID);
             db.CommitTransaction();
         }
         catch
         {
             if (db != null)
             {
                 db.RollbackTransaction();
             }
             throw;
         }
     }
 }
Exemple #9
0
    public frmMaintenance(string mode, clsTimeLogEntry entry)
    {
        InitializeComponent();

        mMode = mode;

        if (mode == "Add")
        {
            Text = "Add Entry";
        }
        else
        {
            Text   = "Update Entry";
            mEntry = entry;

            txtEmployeeID.Text  = mEntry.EmployeeID;
            txtDateWorked.Text  = mEntry.DateWorked.ToShortDateString();
            cboHoursWorked.Text = mEntry.HoursWorked.ToString("#.00");
            chkBillable.Checked = mEntry.Billable;
            txtDescription.Text = mEntry.Description;
        }
    }
    public static List <clsTimeLogEntry> GetAllEntries(TimeLogDate beginDate, TimeLogDate endDate)
    {
        string action         = "getAllEntries";
        string arguments      = "&beginDate=" + beginDate.ToShortDateString() + "&endDate=" + endDate.ToShortDateString();
        string url            = createUrl(action, arguments);
        string responseString = getResponseString(url);

        List <clsTimeLogEntry> entries = new List <clsTimeLogEntry>();

        string[] serializedResponses = responseString.Split('\n');

        foreach (string serializedResponse in serializedResponses)
        {
            if (serializedResponse != "")
            {
                clsTimeLogEntry entry = new clsTimeLogEntry();
                entry.Deserialize(serializedResponse);
                entries.Add(entry);
            }
        }

        return(entries);
    }
 public void Add(clsTimeLogEntry entry)
 {
     clsServer.Add(entry);
 }
 public void Delete(clsTimeLogEntry entry)
 {
     clsServer.Delete(entry);
 }
 public void Update(clsTimeLogEntry entry)
 {
     clsServer.Update(entry);
 }