Exemplo n.º 1
0
        private void addToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            int listIndex = 0;
              Agent agent;
              AddUpdateDialog addDialog = new AddUpdateDialog();

              agent = new Agent();
              agent.SalesID = agentSalesList.AssignID();
              addDialog.agentID = agent.SalesID.ToString();
              addDialog.Text = "Add Agent Sales";
              addDialog.Tag = agent;
              if (addDialog.ShowDialog(this) == DialogResult.OK)
              {
            agent.SalesAmt = Double.Parse(addDialog.salesAmt);
            agent.SalesDate = Date.Parse(addDialog.salesDate);
            agent.AgentName = addDialog.name;
            listIndex = ~this.agentSalesList.BinarySearch(agent, listOrder);
            this.agentSalesList.InsertAt(listIndex, agent);
            this.RefreshClientAreaControls(listIndex);
              }
              addDialog.Dispose();
        }
Exemplo n.º 2
0
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int listIndex;
              Agent agent;
              AddUpdateDialog updateDialog = new AddUpdateDialog();

              listIndex = this.dataGridView.CurrentRow.Index + 1;
              agent = this.agentSalesList[listIndex];
              updateDialog.Text = "Update Agent Sales";
              updateDialog.Tag = agent;
              updateDialog.name = agent.AgentName;
              updateDialog.agentID = agent.SalesID.ToString();
              updateDialog.salesAmt = agent.SalesAmt.ToString("f2");
              updateDialog.salesDate = agent.SalesDate.ToString();
              if (updateDialog.ShowDialog(this) == DialogResult.OK)
              {
            agent.SalesAmt = Double.Parse(updateDialog.salesAmt);
            agent.SalesDate = Date.Parse(updateDialog.salesDate);
            agent.AgentName = updateDialog.name;
            this.agentSalesList.RemoveAt(listIndex);
            listIndex = ~this.agentSalesList.BinarySearch(agent, listOrder);
            this.agentSalesList.InsertAt(listIndex, agent);
            this.RefreshClientAreaControls(listIndex);
              }
              updateDialog.Dispose();
        }