private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            string            message = "Do you want to confirm the parcel details?";
            string            caption = "Confirmation";
            MessageBoxButtons buttons = MessageBoxButtons.OKCancel;
            DialogResult      result;

            result = MessageBox.Show(message, caption, buttons);
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                // Closes the parent form.
                this.Close();
            }
            else
            {
                int senderIDType = 0;
                if (cbIdtype.Text == "IC Number")
                {
                    senderIDType = 1;
                }
                else if (cbIdtype.Text == " Old IC Number")
                {
                    senderIDType = 2;
                }
                else
                {
                    senderIDType = 3;
                }

                bool parcelTypeResult;
                if (rbParcel.Checked)
                {
                    parcelTypeResult = false;
                }
                else
                {
                    parcelTypeResult = true;
                }
                PersonInfo sender1 = new PersonInfo(tbSenderName.Text, tbSenderEmail.Text, tbSenderContactNo.Text, tbSenderAddress.Text,
                                                    tbSenderPosCode.Text, cbSenderLocation.Text, tbSenderCity.Text, tbSenderState.Text);
                PersonInfo receiver1 = new PersonInfo(tbReceiverName.Text, tbReceiverEmail.Text, tbReceiverContactNo.Text, tbReceiverAddress.Text,
                                                      tbReceiverPosCode.Text, cbReceiverLocation.Text, tbReceiverCity.Text, tbReceiverState.Text);
                ParcelInfo parcelInfo = new ParcelInfo(false, parcelTypeResult, Convert.ToByte(tbPieces.Text), tbContent.Text, Convert.ToDecimal(tbValueofContent.Text),
                                                       Convert.ToSingle(tbWeight.Text), Convert.ToDecimal(price.Text), 0);

                ParcelController.Create(Convert.ToByte(senderIDType), tbSenderidNumber.Text, sender1, receiver1, parcelInfo, Authentication.CurrentStaff.BranchId);
                MessageBox.Show("Add Success!");
                this.Close();
                admin.registerHereLoad();
            }
        }
Beispiel #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (ServiceType.Text == "Lodge In")
                {
                    serType = false;
                }
                else
                {
                    serType = true;
                }

                if (ParcelType.Text == "Parcel")
                {
                    parType = false;
                }
                else
                {
                    parType = true;
                }

                if (SenderIDType.Text == "IC Number")
                {
                    idNo = 1;
                }
                else if (SenderIDType.Text == "Old IC Number")
                {
                    idNo = 2;
                }
                else
                {
                    idNo = 3;
                }

                PersonInfo senderInfo = new PersonInfo(SenderName.Text, SenderMail.Text, SenderPhoneNo.Text, addressCheckout.Text,
                                                       postcodeCheckout.Text, locationCheckout.Text, cityCheckout.Text, stateCheckout.Text);

                PersonInfo receiverInfo = new PersonInfo(ReceiverName.Text, ReceiverMail.Text, ReceiverPhoneNo.Text, ReceiverAddress.Text, ReceiverPostal.Text,
                                                         ReceiverLocation.Text, ReceiverCity.Text, ReceiverState.Text);

                ParcelInfo parcelInfo = new ParcelInfo(serType, parType, Convert.ToByte(Piece.Text), Content.Text, Convert.ToDecimal(Value.Text), Convert.ToSingle(Weight.Text),
                                                       Convert.ToDecimal(price.Text), Convert.ToDecimal(pickUpPrice.Text));

                string uid = Authentication.GetUid();
                //byte userIDType = Repository.GetUserIDType(uid);
                // string userIDNo = Convert.ToString(Repository.GetUserIDNumber(uid));


                if (serType == false)
                {
                    int trackingNo = ParcelController.Create(uid, idNo, SenderIDNumber.Text, senderInfo, receiverInfo, parcelInfo, null);
                    Response.Redirect("OrderSummary.aspx?trackNo=" + trackingNo);
                }
                else if (serType == true)
                {
                    DateTime pud;


                    if (!DateTime.TryParseExact(PickUpDate.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out pud))
                    {
                        Response.Write("Problem with date");
                        return;
                    }

                    DateTime put;

                    if (!DateTime.TryParseExact(PickUpTime.Text, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out put))
                    {
                        Response.Write("Problem with time");
                        return;
                    }
                    PickUpInfo pickInfo   = new PickUpInfo(pud, put, Remarks.Text, false);
                    int        trackingNo = ParcelController.Create(uid, idNo, SenderIDNumber.Text, senderInfo, receiverInfo, parcelInfo, pickInfo);
                    Response.Redirect("OrderSummary.aspx?trackNo=" + trackingNo);
                }
            }
            catch (Exception ex)
            {
                if (ex is NullReferenceException)
                {
                    Response.Write("Payment Not Successfully!");
                }

                //if (ex is ThreadAbortException)
                //{
                //    //ignore

                //}
            }
        }