public List <VendorClassificationBE> ListaTodosActivo(int IdVendor)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_VendorClassification_ListaTodosActivo");

            db.AddInParameter(dbCommand, "pIdVendor", DbType.Int32, IdVendor);

            IDataReader reader = db.ExecuteReader(dbCommand);
            List <VendorClassificationBE> VendorClassificationlist = new List <VendorClassificationBE>();
            VendorClassificationBE        VendorClassification;

            while (reader.Read())
            {
                VendorClassification           = new VendorClassificationBE();
                VendorClassification.IdCompany = Int32.Parse(reader["IdCompany"].ToString());
                VendorClassification.IdVendor  = Int32.Parse(reader["IdVendor"].ToString());
                VendorClassification.IdVendorClassification = Int32.Parse(reader["idVendorClassification"].ToString());
                VendorClassification.IdClassification       = Int32.Parse(reader["IdClassification"].ToString());
                VendorClassification.NameClassification     = reader["NameClassification"].ToString();
                VendorClassification.FlagActive             = Boolean.Parse(reader["FlagActive"].ToString());
                VendorClassification.FlagState = Boolean.Parse(reader["FlagState"].ToString());
                VendorClassification.TipoOper  = 4; //CONSULTAR
                VendorClassificationlist.Add(VendorClassification);
            }
            reader.Close();
            reader.Dispose();
            return(VendorClassificationlist);
        }
        public VendorClassificationBE Selecciona(int IdVendorClassification)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_VendorClassification_Selecciona");

            db.AddInParameter(dbCommand, "pidVendorClassification", DbType.Int32, IdVendorClassification);

            IDataReader            reader = db.ExecuteReader(dbCommand);
            VendorClassificationBE VendorClassification = null;

            while (reader.Read())
            {
                VendorClassification           = new VendorClassificationBE();
                VendorClassification.IdCompany = Int32.Parse(reader["IdCompany"].ToString());
                VendorClassification.IdVendor  = Int32.Parse(reader["IdVendor"].ToString());
                VendorClassification.IdVendorClassification = Int32.Parse(reader["idVendorClassification"].ToString());
                VendorClassification.IdClassification       = Int32.Parse(reader["IdClassification"].ToString());
                VendorClassification.NameClassification     = reader["NameClassification"].ToString();
                VendorClassification.FlagActive             = Boolean.Parse(reader["FlagActive"].ToString());
                VendorClassification.FlagState = Boolean.Parse(reader["FlagState"].ToString());
            }
            reader.Close();
            reader.Dispose();
            return(VendorClassification);
        }
Esempio n. 3
0
 public void Elimina(VendorClassificationBE pItem)
 {
     try
     {
         VendorClassificationDL VendorClassification = new VendorClassificationDL();
         VendorClassification.Elimina(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Esempio n. 4
0
 public VendorClassificationBE Selecciona(int IdVendorClassification)
 {
     try
     {
         VendorClassificationDL VendorClassification = new VendorClassificationDL();
         VendorClassificationBE objEmp = VendorClassification.Selecciona(IdVendorClassification);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
        public void Elimina(VendorClassificationBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_VendorClassification_Elimina");

            db.AddInParameter(dbCommand, "pIdVendorClassification", DbType.Int32, pItem.IdVendorClassification);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);

            db.ExecuteNonQuery(dbCommand);
        }
        public void Actualiza(VendorClassificationBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_VendorClassification_Actualiza");

            db.AddInParameter(dbCommand, "pIdVendorClassification", DbType.Int32, pItem.IdVendorClassification);
            db.AddInParameter(dbCommand, "pIdVendor", DbType.Int32, pItem.IdVendor);
            db.AddInParameter(dbCommand, "pIdClassification", DbType.Int32, pItem.IdClassification);
            db.AddInParameter(dbCommand, "pFlagActive", DbType.Boolean, pItem.FlagActive);
            db.AddInParameter(dbCommand, "pFlagState", DbType.Boolean, pItem.FlagState);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.ExecuteNonQuery(dbCommand);
        }
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (!ValidarIngreso())
                {
                    VendorBE objVendor    = new VendorBE();
                    VendorBL objBL_Vendor = new VendorBL();

                    objVendor.IdVendor        = IdVendor;
                    objVendor.NameVendor      = txtNameVendor.Text;
                    objVendor.FlagNational    = (chkNational.Checked) ? true : false;
                    objVendor.FlagForeigner   = (chkForeigner.Checked) ? true : false;
                    objVendor.RevenueDate     = Convert.ToDateTime(deRevenueDate.DateTime.ToShortDateString());
                    objVendor.IdStatus        = (int)cboStatus.EditValue;
                    objVendor.Ruc             = txtRuc.Text;
                    objVendor.NameVendor      = txtNameVendor.Text;
                    objVendor.IdEvaluation    = (int)cboEvaluation.EditValue;
                    objVendor.Code            = txtVendorCode.Text;
                    objVendor.Corporation     = txtCorporation.Text;
                    objVendor.Capacity        = Convert.ToDecimal(txtCapacity.EditValue);
                    objVendor.Representative  = txtRepresentative.Text;
                    objVendor.NumberEmployees = Convert.ToInt32(txtNumberEmployees.EditValue);
                    objVendor.FlagState       = true;
                    objVendor.Login           = Parametros.strUsuarioLogin;
                    objVendor.Machine         = WindowsIdentity.GetCurrent().Name.ToString();
                    objVendor.IdCompany       = Parametros.intEmpresaId;

                    //Vendor ADDRESS
                    List <VendorAddressBE> lstVendorAddress = new List <VendorAddressBE>();

                    foreach (var item in mListaVendorAddressOrigen)
                    {
                        VendorAddressBE objE_VendorAddress = new VendorAddressBE();
                        objE_VendorAddress.IdCompany       = Parametros.intEmpresaId;
                        objE_VendorAddress.IdVendor        = IdVendor;
                        objE_VendorAddress.IdVendorAddress = item.IdVendorAddress;
                        objE_VendorAddress.IdType          = item.IdType;
                        objE_VendorAddress.Email           = item.Email;
                        objE_VendorAddress.WebPage         = item.WebPage;
                        objE_VendorAddress.Address         = item.Address;
                        objE_VendorAddress.IdUbigeo        = item.IdUbigeo;
                        objE_VendorAddress.City            = item.City;
                        objE_VendorAddress.State           = item.State;
                        objE_VendorAddress.IdCountry       = item.IdCountry;
                        objE_VendorAddress.Phone1          = item.Phone1;
                        objE_VendorAddress.Phone2          = item.Phone2;
                        objE_VendorAddress.Fax             = item.Fax;
                        objE_VendorAddress.Reference       = item.Reference;
                        objE_VendorAddress.FlagState       = true;
                        objE_VendorAddress.Login           = Parametros.strUsuarioLogin;
                        objE_VendorAddress.Machine         = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorAddress.TipoOper        = item.TipoOper;
                        lstVendorAddress.Add(objE_VendorAddress);
                    }

                    //Vendor CONTACT
                    List <VendorContactBE> lstVendorContact = new List <VendorContactBE>();

                    foreach (var item in mListaVendorContactOrigen)
                    {
                        VendorContactBE objE_VendorContact = new VendorContactBE();
                        objE_VendorContact.IdCompany             = Parametros.intEmpresaId;
                        objE_VendorContact.IdVendor              = IdVendor;
                        objE_VendorContact.IdVendorContact       = item.IdVendorContact;
                        objE_VendorContact.Name                  = item.Name;
                        objE_VendorContact.FirstName             = item.FirtsName;
                        objE_VendorContact.Company               = item.Company;
                        objE_VendorContact.Occupation            = item.Occupation;
                        objE_VendorContact.IdDestination         = item.IdDestination;
                        objE_VendorContact.Phone1                = item.Phone1;
                        objE_VendorContact.Phone2                = item.Phone2;
                        objE_VendorContact.CelPhone              = item.CelPhone;
                        objE_VendorContact.Fax                   = item.Fax;
                        objE_VendorContact.Email                 = item.Email;
                        objE_VendorContact.InformationAdditional = item.InformationAdditional;
                        objE_VendorContact.FlagState             = true;
                        objE_VendorContact.Login                 = Parametros.strUsuarioLogin;
                        objE_VendorContact.Machine               = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorContact.TipoOper              = item.TipoOper;
                        lstVendorContact.Add(objE_VendorContact);
                    }

                    //Vendor Classification
                    List <VendorClassificationBE> lstVendorClassification = new List <VendorClassificationBE>();

                    foreach (var item in mListaVendorClassificationOrigen)
                    {
                        VendorClassificationBE objE_VendorClassification = new VendorClassificationBE();
                        objE_VendorClassification.IdCompany = Parametros.intEmpresaId;
                        objE_VendorClassification.IdVendor  = IdVendor;
                        objE_VendorClassification.IdVendorClassification = item.IdVendorClassification;
                        objE_VendorClassification.IdClassification       = item.IdClassification;
                        objE_VendorClassification.NameClassification     = item.NameClassification;
                        objE_VendorClassification.FlagActive             = item.FlagActive;
                        objE_VendorClassification.FlagState = true;
                        objE_VendorClassification.Login     = Parametros.strUsuarioLogin;
                        objE_VendorClassification.Machine   = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_VendorClassification.TipoOper  = item.TipoOper;
                        lstVendorClassification.Add(objE_VendorClassification);
                    }


                    if (pOperacion == Operacion.Nuevo)
                    {
                        objBL_Vendor.Inserta(objVendor, lstVendorAddress, lstVendorContact, lstVendorClassification);
                        XtraMessageBox.Show("the vendor record was created.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        objBL_Vendor.Actualiza(objVendor, lstVendorAddress, lstVendorContact, lstVendorClassification);
                        XtraMessageBox.Show("the vendor record was updated.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }