コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            clsAdmin adminagent = new clsAdmin();
            clsAgent temp       = new clsAgent();

            temp.UserID      = txtID.Text.Trim();
            temp.Name        = txtName.Text.Trim();
            temp.PhoneNumber = txtPhone.Text.Trim();
            temp.SalesPoint  = Convert.ToInt32(txtSalesPoint.Text);
            temp.RefClient   = Convert.ToInt32(txtClient.Text);
            if (Addmode)
            {
                if (adminagent.Add_New_Agent(temp))
                {
                    MessageBox.Show("New Agent " + temp.Name + " is successfully added", "New Agent");
                }
                else
                {
                    MessageBox.Show("Agent " + temp.Name + " is not added.", "Try Again");
                }
                admin.Refresh_Database();
            }
            else
            {
                temp.RefAgent = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;
                if (adminagent.Edit_Agent(temp))
                {
                    MessageBox.Show("Agent " + temp.Name + " is successfully modified", "Agent Modified");
                }
                else
                {
                    MessageBox.Show("Agent " + temp.Name + " is not edited.", "Try Again");
                }
            }
            gridAll.DataSource = admin.Search_All_Agents();
            ButtonControl(true, true, false, false, true, false);
        }