コード例 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            LblMessage.Text = "";
            Application.DoEvents();

            var target = ValidateFields();

            if (target != null)
            {
                LblMessage.Text = "Required fields not filled in.";
                target.Focus();
                target.BackColor = Color.Yellow;
                return;
            }

            var id = (CurrentPerson != null ? CurrentPerson.PeopleID : null);

            CurrentPerson = new Person()
            {
                PeopleID   = id,
                FirstName  = TxtFirstName.Text,
                LastName   = TxtLastName.Text,
                Address1   = TxtAddress1.Text,
                Address2   = TxtAddress2.Text,
                City       = TxtCity.Text,
                State      = ((USState)CmbState.SelectedItem).Abbreviation,
                ZipCode    = TxtZip.Text,
                Country    = TxtCountry.Text,
                Phone1     = TxtPhone1.Text,
                Phone1Type = TxtPhone1.TextLength > 0 ? (string)CmbPhoneType1.SelectedItem : "",
                Phone2     = TxtPhone2.Text,
                Phone2Type = TxtPhone2.TextLength > 0 ? (string)CmbPhoneType2.SelectedItem : "",
                Email      = TxtEmail.Text,
                BadgeName  =
                    (TxtBadgeName.Text != "" ? TxtBadgeName.Text : TxtFirstName.Text + " " + TxtLastName.Text),
                Banned    = ChkBanned.Checked,
                HeardFrom = TxtHeardFrom.Text
            };
            if (id == null)
            {
                CurrentPerson.Save(TxtPassword1.Text);
            }
            else
            {
                CurrentPerson.Save();
            }

            if (CurrentPerson.LastError != null)
            {
                LblMessage.Text = "An error occurred trying to save the account: " + CurrentPerson.LastError;
            }
            else
            {
                LblMessage.Text = "Account saved successfully.";
            }
        }
コード例 #2
0
        private void BtnContinue_Click(object sender, EventArgs e)
        {
            if (useNewPerson)
            {
                Person.Save();
            }
            var sales = useNewPerson ?
                        new FrmSellItems(Person) :
                        new FrmSellItems((Person)LstPeople.SelectedItems[0].Tag);

            sales.ShowDialog();
            LstPeople.SelectedItems.Clear();
            TxtLastName.Text      = "";
            TxtRecipientName.Text = "";
            Person = null;
        }
コード例 #3
0
        private void BtnTransfer_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            if (useNewPerson)
            {
                Person.Save();
            }
            var targetPerson = useNewPerson ? Person : (Person)LstPeople.SelectedItems[0].Tag;

            var payload = "action=ModifyBadge&badgeAction=Transfer&badgeID=" + TransferBadge.BadgeID + "&newID=" +
                          targetPerson.PeopleID + "&badgeName=" + HttpUtility.UrlEncode(TxtBadgeName.Text);

            var data = Encoding.ASCII.GetBytes(payload);

            var request = WebRequest.Create(Program.URL + "/functions/userQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var webResponse = (HttpWebResponse)request.GetResponse();
            var results     = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
            var response    = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(results);

            if ((string)response["result"] == "Success")
            {
                MessageBox.Show("Badge successfully transferred to " + TxtRecipientName.Text + ".", "Success",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                TransferBadge.BadgeName = TxtBadgeName.Text;
                TransferBadge.FirstName = targetPerson.FirstName;
                TransferBadge.LastName  = targetPerson.LastName;
                DialogResult            = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Failed to create record for new person: " + (string)response["message"], "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Cursor = Cursors.Default;
        }