0

サービス参照を含む Web フォーム アプリケーションがあり、mvc4 でフロントエンドのみを書き直す必要があります。

検索ボタンに問題があります(プログラミングはまだ初めてです)これはWebフォームのコードです

private void btnSearch_Click(object sender, EventArgs e)
    {

        ClearViewers();
        btnSearch.Enabled = false;
        btnSyncronise.Enabled = false;

        PersonalInformation localInfo = null;
        PersonInfo[] registryInfo = null;

        needsUpdate = false;

        Cursor = Cursors.WaitCursor;


        try
        {
            if ((String.IsNullOrEmpty(txtPersonalNumber.Text)) || (txtPersonalNumber.Text.Length != 11) || (Regex.Match(txtPersonalNumber.Text, "^\\d{11}$").Success == false))
            {
                MessageBox.Show(@"blabla" + Environment.NewLine + @"blablabla" + Environment.NewLine + @"blabla", @"blabla", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (PersonalInfoServiceClient proxy = new PersonalInfoServiceClient())
            {
                try
                {
                    localInfo = proxy.GetLocalInfoForPerson(txtPersonalNumber.Text.Trim());

                    if (localInfo != null)
                    {

                        ssStatusLocal.ForeColor = Color.Green;
                        ssStatusLocal.Text = @"found personal ID";

                        lblFirstName.Text = localInfo.FirstName;
                        lblLastName.Text = localInfo.LastName;
                        lblMiddleName.Text = localInfo.MiddleName;
                        lblBirthDate.Text = String.Format("{0:MM/dd/yyyy}", localInfo.BirthDate);

                        if (localInfo.PersonStatus == PersonStatus.Active)
                            lblStatus.Text = @"active";

                        else if (localInfo.PersonStatus == PersonStatus.Rejected)
                            lblStatus.Text = @"passive";

                        else if (localInfo.PersonStatus == PersonStatus.Dead)
                            lblStatus.Text = @"dead";

                        else
                            lblStatus.Text = @"unknown";


                        lblSex.Text = (Convert.ToInt32(localInfo.Sex) == 1) ? @"male" : @"female";
                        lblAddress.Text = localInfo.Address;
                        lbBirthPlace.Text = localInfo.BirthPlace;
                        lbCitizenShip.Text = (string.IsNullOrEmpty(localInfo.CitizenShip) && string.IsNullOrEmpty(localInfo.CitizenShipCode)) ? localInfo.CitizenShip : localInfo.CitizenShip + " / " + localInfo.CitizenShipCode;
                        lbDoubleCitizenShip.Text = (string.IsNullOrEmpty(localInfo.DoubleCitizenShip) && string.IsNullOrEmpty(localInfo.DoubleCitizenShipCode)) ? localInfo.DoubleCitizenShip : localInfo.DoubleCitizenShip + " / " + localInfo.DoubleCitizenShipCode;
                        lblRegion.Text = localInfo.RegionName;

                        if (localInfo.Photo != null)
                        {
                            MemoryStream MS = new MemoryStream(localInfo.Photo);
                            pictureBox2.Image = Image.FromStream(MS);
                        }

                        documentInformationBindingSource1.DataSource = localInfo.Documents;
                    }
                    else
                    {
                        ssStatusLocal.ForeColor = Color.Red;
                        ssStatusLocal.Text = @"personal ID not found";
                    }
                }
                catch
                {
                    ssStatusLocal.ForeColor = Color.Red;
                    ssStatusLocal.Text = @"error";

                    throw;
                }


                try
                {
                    registryInfo = proxy.GetRegistryInfoForPerson(txtPersonalNumber.Text.Trim());

                    if (registryInfo != null && registryInfo.Length > 0)
                    {

                        ssStatusCivil.ForeColor = Color.Green;
                        ssStatusCivil.Text = @"found personal ID";

                        btnSyncronise.Enabled = true;

                        RegistryPersonInfos list = new RegistryPersonInfos();
                        foreach (PersonInfo personInfo in registryInfo)
                        {
                            RegistryPersonInfo registryPersonInfo = new RegistryPersonInfo()
                            {
                                BirthDate = personInfo.BirthDate
                                ,
                                IsDead = (personInfo.IsPersonDead) ? "yes" : "no"
                                ,
                                FirstName = personInfo.FirstName
                                ,
                                LastName = personInfo.LastName
                                ,
                                MiddleName = personInfo.MiddleName
                                ,
                                DocumentStatusName = personInfo.DocumentStatusStr
                                ,
                                DocumentStatus = personInfo.DocumentStatusEnum.ToString()
                                ,
                                PersonalNumber = personInfo.PrivateNumber
                                ,
                                DocumentRejectDate = personInfo.RejectedDate
                                ,
                                DocumentType = (personInfo.IsIdCard) ? (string.IsNullOrEmpty(personInfo.IdCardNumber)) ? "one" : "two" : "three"
                                ,
                                DocumentSerie = (personInfo.IsIdCard) ? personInfo.IdCardSerial : string.Empty
                                ,
                                DocumentNumber = (personInfo.IsIdCard) ? (string.IsNullOrEmpty(personInfo.IdCardNumber)) ? string.Empty : personInfo.IdCardNumber : personInfo.PaspNumber
                            };

                            list.Add(registryPersonInfo);
                        }

                        registryPersonInfoBindingSource.DataSource = list;
                    }
                    else
                    {
                        ssStatusCivil.ForeColor = Color.Red;
                        ssStatusCivil.Text = @"Personal ID not found";
                    }

                }
                catch
                {
                    ssStatusCivil.ForeColor = Color.Red;
                    ssStatusCivil.Text = @"error";
                    throw;
                }
            }
        }
        catch (Exception x)
        {
            lblFirstName.Text = String.Empty;
            lblLastName.Text = String.Empty;
            lblMiddleName.Text = String.Empty;
            lblStatus.Text = String.Empty;
            needsUpdate = false;
            dgwMain.DataSource = null;

            MessageBox.Show(
                String.Format(
                    "error during loading. {0} error: {1} {2} info: {3}",
                    Environment.NewLine, x.Message, Environment.NewLine,
                    (x.InnerException == null) ? string.Empty : x.InnerException.Message), @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            Cursor = Cursors.Default;
            btnSearch.Enabled = true;
        }

    }

これをコントローラーにどのように記述しますか?コントローラーはラベルを見つけることができません。ピクチャーボックスはありません サービス参照を介してデータを取得する方法がわかりません

手伝ってくれる ?

4

0 に答える 0