示例#1
0
        public void Select()
        {
            bool             result          = false;
            BAudit           bAudit          = new BAudit();
            List <EAudit>    listAudit       = new List <EAudit>();
            BClient          bClient         = new BClient();
            EClient          eClient         = new EClient();
            EClient          selectedEClient = new EClient();
            TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew);

            eClient.CodeTypeDocumentIdentity = "0";
            eClient.NumberIdentity           = Aleatory.GetString(11);
            eClient.FirstName          = Aleatory.GetString(8);
            eClient.SecondName         = Aleatory.GetString(8);
            eClient.FatherLastName     = Aleatory.GetString(8);
            eClient.MotherLastName     = Aleatory.GetString(8);
            eClient.Audit.UserRegister = Aleatory.GetString(8);
            EClient insertedEClient = bClient.Insert(eClient);

            selectedEClient = bClient.Select(insertedEClient);

            if (selectedEClient != null &&
                selectedEClient.CodeClient == insertedEClient.CodeClient &&
                selectedEClient.SearchName == insertedEClient.SearchName &&
                selectedEClient.State == insertedEClient.State)
            {
                result = true;
            }

            ts.Dispose();

            Assert.IsTrue(result);
        }
示例#2
0
        public void Update()
        {
            bool             result    = false;
            BAudit           bAudit    = new BAudit();
            List <EAudit>    listAudit = new List <EAudit>();
            BClient          bClient   = new BClient();
            EClient          eClient   = new EClient();
            TransactionScope ts        = new TransactionScope(TransactionScopeOption.RequiresNew);

            eClient.CodeTypeDocumentIdentity = "0";
            eClient.NumberIdentity           = Aleatory.GetString(11);
            eClient.FirstName          = Aleatory.GetString(8);
            eClient.SecondName         = Aleatory.GetString(8);
            eClient.FatherLastName     = Aleatory.GetString(8);
            eClient.MotherLastName     = Aleatory.GetString(8);
            eClient.Audit.UserRegister = Aleatory.GetString(8);
            EClient insertedEClient = bClient.Insert(eClient);

            insertedEClient.FirstName          = Aleatory.GetString(8);
            insertedEClient.SecondName         = Aleatory.GetString(8);
            insertedEClient.FatherLastName     = Aleatory.GetString(8);
            insertedEClient.MotherLastName     = Aleatory.GetString(8);
            insertedEClient.Audit.UserRegister = Aleatory.GetString(8);
            EClient updatedEClient = bClient.Update(insertedEClient);

            listAudit = bAudit.Select(eClient.Audit);

            if (updatedEClient != null &&
                updatedEClient.SearchName != eClient.SearchName &&
                listAudit.Count > 0 &&
                listAudit.Exists(
                    x => x.UserRegister == insertedEClient.Audit.UserRegister &&
                    x.Code == updatedEClient.CodeClient.ToString() &&
                    x.TypeEvent == "Update"))
            {
                result = true;
            }

            ts.Dispose();

            Assert.IsTrue(result);
        }
示例#3
0
        public void Insert()
        {
            bool             result    = false;
            BAudit           bAudit    = new BAudit();
            List <EAudit>    listAudit = new List <EAudit>();
            BClient          bClient   = new BClient();
            EClient          eClient   = new EClient();
            BSequence        bSequence = new BSequence();
            ESequence        eSequence = null;
            TransactionScope ts        = new TransactionScope(TransactionScopeOption.RequiresNew);

            eClient.CodeTypeDocumentIdentity = "0";
            eClient.NumberIdentity           = Aleatory.GetString(11);
            eClient.FirstName          = Aleatory.GetString(8);
            eClient.SecondName         = Aleatory.GetString(8);
            eClient.FatherLastName     = Aleatory.GetString(8);
            eClient.MotherLastName     = Aleatory.GetString(8);
            eClient.Audit.UserRegister = Aleatory.GetString(8);
            EClient insertedEClient = bClient.Insert(eClient);

            eSequence = new ESequence(eClient);
            eSequence = bSequence.Select(eSequence);

            listAudit = bAudit.Select(eClient.Audit);

            if (insertedEClient != null &&
                listAudit.Exists(x => x.UserRegister == eClient.Audit.UserRegister &&
                                 x.TypeEvent == "Insert" &&
                                 x.Code == insertedEClient.CodeClient.ToString()) &&
                eSequence.Correlative == insertedEClient.CodeClient + 1)
            {
                result = true;
            }

            ts.Dispose();

            Assert.IsTrue(result);
        }
示例#4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (txtName.Text == string.Empty)
                {
                    MessageError("Fill the fields");
                    errorIcon.SetError(txtName, "Insert the client's name");
                }
                else
                {
                    if (this.eNew)
                    {
                        resp = BClient.Insert(
                            this.txtName.Text.Trim().ToUpper(),
                            this.txtSurname.Text,
                            this.cbGender.Text,
                            this.dtDate.Value,
                            this.cbDocType.Text,
                            this.txtDocNumber.Text,
                            this.txtAddress.Text,
                            this.txtPhone.Text,
                            this.txtEmail.Text

                            );
                    }
                    else
                    {
                        resp = BClient.Edit(Convert.ToInt32(this.txtId.Text),
                                            this.txtName.Text.Trim().ToUpper(), this.txtSurname.Text,
                                            this.cbGender.Text, this.dtDate.Value, this.cbDocType.Text,
                                            this.txtDocNumber.Text, this.txtAddress.Text, this.txtPhone.Text, this.txtEmail.Text
                                            );
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.eNew)
                        {
                            this.MessageOk("Client saved");
                        }
                        else
                        {
                            this.MessageOk("Client Edited");
                        }
                    }
                    else
                    {
                        this.MessageError(resp);
                    }

                    this.eNew  = false;
                    this.eEdit = false;
                    this.Enabledbuttons();
                    this.Clean();
                    this.ShowValues();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }