Exemplo n.º 1
0
        private List <SupplierList> GetData(int pintPageIndex, int?pintPageSize, string pstrSortExpression, string pstrFilterExpression)
        {
            OperationResult objOperationResult = new OperationResult();
            var             _objData           = _objBL.GetSuppliersPagedAndFiltered(ref objOperationResult, pintPageIndex, pintPageSize, pstrSortExpression, pstrFilterExpression);

            if (objOperationResult.Success != 1)
            {
                MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(_objData);
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            string          pstrFilterEpression;

            if (uvOrganization.Validate(true, false).IsValid)
            {
                if (txtIdentificationNumber.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor ingrese un nombre apropiado para la Nro Identificación.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (txtName.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor ingrese un nombre apropiado para la Razón Social.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                //if (!Common.Utils.ValidateIdentificationDocumentPeru(txtIdentificationNumber.Text))
                //{
                //    MessageBox.Show("El Nro. identificación es errado .", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}
                if (_Mode == "New")
                {
                    _supplierDto = new supplierDto();
                    // Populate the entity
                    _supplierDto.i_SectorTypeId         = int.Parse(ddlSectorTypeId.SelectedValue.ToString());
                    _supplierDto.v_IdentificationNumber = txtIdentificationNumber.Text.Trim();
                    _supplierDto.v_Name        = txtName.Text.Trim();
                    _supplierDto.v_Address     = txtAddress.Text.Trim();
                    _supplierDto.v_PhoneNumber = txtPhoneNumber.Text.Trim();
                    _supplierDto.v_Mail        = txtEmail.Text.Trim();

                    pstrFilterEpression = "i_IsDeleted==0 && v_IdentificationNumber==(\"" + txtIdentificationNumber.Text.Trim() + "\")";
                    if (_objBL.GetSuppliersPagedAndFiltered(ref objOperationResult, null, null, null, pstrFilterEpression).Count() != 0)
                    {
                        MessageBox.Show("El Nro. Identificación ya existe:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else
                    {
                        // Save the data
                        _objBL.AddSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList());
                    }
                }
                else if (_Mode == "Edit")
                {
                    // Populate the entity
                    _supplierDto.v_SupplierId           = _SupplierId;
                    _supplierDto.i_SectorTypeId         = int.Parse(ddlSectorTypeId.SelectedValue.ToString());
                    _supplierDto.v_IdentificationNumber = txtIdentificationNumber.Text.Trim();
                    _supplierDto.v_Name        = txtName.Text.Trim();
                    _supplierDto.v_Address     = txtAddress.Text.Trim();
                    _supplierDto.v_PhoneNumber = txtPhoneNumber.Text.Trim();
                    _supplierDto.v_Mail        = txtEmail.Text.Trim();

                    if (_Temp_IdentificationNumber == _supplierDto.v_IdentificationNumber)
                    {
                        // Save the data
                        _objBL.UpdateSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList());
                    }
                    else
                    {
                        pstrFilterEpression = "i_IsDeleted==0 && v_IdentificationNumber==(\"" + txtIdentificationNumber.Text.Trim() + "\")";
                        if (_objBL.GetSuppliersPagedAndFiltered(ref objOperationResult, null, null, null, pstrFilterEpression).Count() != 0)
                        {
                            MessageBox.Show("El Nro Identificación ya existe:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        else
                        {
                            // Save the data
                            _objBL.UpdateSupplier(ref objOperationResult, _supplierDto, Globals.ClientSession.GetAsList());
                        }
                    }
                }


                //// Analizar el resultado de la operación
                if (objOperationResult.Success == 1)  // Operación sin error
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                else  // Operación con error
                {
                    MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Se queda en el formulario.
                }
            }
            else
            {
                MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }