コード例 #1
0
        public void Actualiza(VendorBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Vendor_Actualiza");

            db.AddInParameter(dbCommand, "pIdVendor", DbType.Int32, pItem.IdVendor);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pFlagNational", DbType.Boolean, pItem.FlagNational);
            db.AddInParameter(dbCommand, "pFlagForeigner", DbType.Boolean, pItem.FlagForeigner);
            db.AddInParameter(dbCommand, "pRevenueDate", DbType.DateTime, pItem.RevenueDate);
            db.AddInParameter(dbCommand, "pIdStatus", DbType.Int32, pItem.IdStatus);
            db.AddInParameter(dbCommand, "pRuc", DbType.String, pItem.Ruc);
            db.AddInParameter(dbCommand, "pNameVendor", DbType.String, pItem.NameVendor);
            db.AddInParameter(dbCommand, "pIdEvaluation", DbType.Int32, pItem.IdEvaluation);
            db.AddInParameter(dbCommand, "pCode", DbType.String, pItem.Code);
            db.AddInParameter(dbCommand, "pCorporation", DbType.String, pItem.Corporation);
            db.AddInParameter(dbCommand, "pCapacity", DbType.Decimal, pItem.Capacity);
            db.AddInParameter(dbCommand, "pRepresentative", DbType.String, pItem.Representative);
            db.AddInParameter(dbCommand, "pNumberEmployees", DbType.Int32, pItem.NumberEmployees);
            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.ExecuteNonQuery(dbCommand);
        }
コード例 #2
0
        private void tlbMenu_DeleteClick()
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (XtraMessageBox.Show("Be sure to delete the record?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (!ValidarIngreso())
                    {
                        VendorBE objE_Vendor = new VendorBE();
                        objE_Vendor.IdVendor  = int.Parse(gvVendor.GetFocusedRowCellValue("IdVendor").ToString());
                        objE_Vendor.Login     = Parametros.strUsuarioLogin;
                        objE_Vendor.Machine   = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_Vendor.IdCompany = Parametros.intEmpresaId;

                        VendorBL objBL_Vendor = new VendorBL();
                        objBL_Vendor.Elimina(objE_Vendor);
                        XtraMessageBox.Show("The record was successfully deleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Cargar();
                    }
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void frmRegVendorEdit_Load(object sender, EventArgs e)
        {
            BSUtils.LoaderLook(cboEvaluation, new EvaluationBL().ListaTodosActivo(Parametros.intEmpresaId), "NameEvaluation", "IdEvaluation", true);
            cboEvaluation.EditValue = 0;
            BSUtils.LoaderLook(cboStatus, new StatusBL().ListaTodosActivo(Parametros.intEmpresaId), "NameStatus", "IdStatus", true);
            cboEvaluation.EditValue = 0;
            deRevenueDate.DateTime  = DateTime.Now;

            if (pOperacion == Operacion.Nuevo)
            {
                this.Text = "Vendor - New";
                CargaVendorClassificationNuevo();
            }
            else if (pOperacion == Operacion.Modificar)
            {
                this.Text = "Vendor - Update";

                VendorBE objE_Vendor = null;
                objE_Vendor = new VendorBL().Selecciona(IdVendor);
                if (objE_Vendor != null)
                {
                    IdVendor                = objE_Vendor.IdVendor;
                    txtNameVendor.Text      = objE_Vendor.NameVendor;
                    txtRuc.Text             = objE_Vendor.Ruc;
                    cboStatus.EditValue     = objE_Vendor.IdStatus;
                    cboEvaluation.EditValue = objE_Vendor.IdEvaluation;
                    deRevenueDate.EditValue = objE_Vendor.RevenueDate;
                    if (objE_Vendor.FlagNational)
                    {
                        chkNational.Checked = true;
                    }
                    else
                    {
                        chkNational.Checked = false;
                    }
                    if (objE_Vendor.FlagForeigner)
                    {
                        chkForeigner.Checked = true;
                    }
                    else
                    {
                        chkForeigner.Checked = false;
                    }
                    txtVendorCode.Text           = objE_Vendor.Code;
                    txtCorporation.EditValue     = objE_Vendor.Corporation;
                    txtRepresentative.EditValue  = objE_Vendor.Representative;
                    txtCapacity.EditValue        = objE_Vendor.Capacity;
                    txtNumberEmployees.EditValue = objE_Vendor.NumberEmployees;
                    txtSituation.Text            = objE_Vendor.Situation;

                    CargaVendorClassificationModificar();
                }
            }

            CargaVendorAddress();
            CargaVendorContact();

            txtNameVendor.Focus();
        }
コード例 #4
0
        public void Actualiza(VendorBE pItem, List <VendorAddressBE> pListaVendorAddress, List <VendorContactBE> pListaVendorContact, List <VendorClassificationBE> pListaVendorClassification)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    foreach (var item in pListaVendorAddress)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorAddress.Inserta(item);
                        }
                        else
                        {
                            VendorAddress.Actualiza(item);
                        }
                    }

                    foreach (var item in pListaVendorContact)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorContact.Inserta(item);
                        }
                        else
                        {
                            VendorContact.Actualiza(item);
                        }
                    }

                    foreach (var item in pListaVendorClassification)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorClassification.Inserta(item);
                        }
                        else
                        {
                            VendorClassification.Actualiza(item);
                        }
                    }

                    Vendor.Actualiza(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
コード例 #5
0
 public VendorBE Selecciona(int IdVendor)
 {
     try
     {
         VendorDL Vendor = new VendorDL();
         VendorBE objEmp = Vendor.Selecciona(IdVendor);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #6
0
        public void Elimina(VendorBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Vendor_Elimina");

            db.AddInParameter(dbCommand, "pIdVendor", DbType.Int32, pItem.IdVendor);
            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);
        }
コード例 #7
0
        public void Elimina(VendorBE pItem)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    List <VendorAddressBE> lstVendorAddress = null;
                    lstVendorAddress = new VendorAddressDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorAddress)
                    {
                        VendorAddress.Elimina(item);
                    }

                    List <VendorContactBE> lstVendorContact = null;
                    lstVendorContact = new VendorContactDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorContact)
                    {
                        VendorContact.Elimina(item);
                    }

                    List <VendorClassificationBE> lstVendorClassification = null;
                    lstVendorClassification = new VendorClassificationDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorClassification)
                    {
                        VendorClassification.Elimina(item);
                    }



                    Vendor.Elimina(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
コード例 #8
0
        public Int32 Inserta(VendorBE pItem, List <VendorAddressBE> pListaVendorAddress, List <VendorContactBE> pListaVendorContact, List <VendorClassificationBE> pListaVendorClassification)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    int IdVendor = 0;
                    IdVendor = Vendor.Inserta(pItem);

                    foreach (var item in pListaVendorAddress)
                    {
                        item.IdVendor = IdVendor;
                        VendorAddress.Inserta(item);
                    }

                    foreach (var item in pListaVendorContact)
                    {
                        item.IdVendor = IdVendor;
                        VendorContact.Inserta(item);
                    }

                    foreach (var item in pListaVendorClassification)
                    {
                        item.IdVendor = IdVendor;
                        VendorClassification.Inserta(item);
                    }


                    ts.Complete();

                    return(IdVendor);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
コード例 #9
0
        public void InicializarModificar()
        {
            if (gvVendor.RowCount > 0)
            {
                VendorBE objVendor = new VendorBE();

                objVendor.IdVendor = int.Parse(gvVendor.GetFocusedRowCellValue("IdVendor").ToString());

                frmRegVendorEdit objManVendorEdit = new frmRegVendorEdit();
                objManVendorEdit.pOperacion    = frmRegVendorEdit.Operacion.Modificar;
                objManVendorEdit.IdVendor      = objVendor.IdVendor;
                objManVendorEdit.StartPosition = FormStartPosition.CenterParent;
                objManVendorEdit.ShowDialog();

                Cargar();
            }
            else
            {
                MessageBox.Show("No se pudo editar");
            }
        }
コード例 #10
0
        public List <VendorBE> ListaTodosActivo(int IdCompany)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Vendor_ListaTodosActivo");

            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, IdCompany);

            IDataReader     reader     = db.ExecuteReader(dbCommand);
            List <VendorBE> Vendorlist = new List <VendorBE>();
            VendorBE        Vendor;

            while (reader.Read())
            {
                Vendor                 = new VendorBE();
                Vendor.IdVendor        = Int32.Parse(reader["IdVendor"].ToString());
                Vendor.IdCompany       = Int32.Parse(reader["IdCompany"].ToString());
                Vendor.FlagNational    = Boolean.Parse(reader["FlagNational"].ToString());
                Vendor.FlagForeigner   = Boolean.Parse(reader["FlagForeigner"].ToString());
                Vendor.RevenueDate     = DateTime.Parse(reader["RevenueDate"].ToString());
                Vendor.NameVendor      = reader["NameVendor"].ToString();
                Vendor.IdStatus        = Int32.Parse(reader["IdStatus"].ToString());
                Vendor.NameStatus      = reader["NameStatus"].ToString();
                Vendor.Ruc             = reader["Ruc"].ToString();
                Vendor.NameVendor      = reader["NameVendor"].ToString();
                Vendor.IdEvaluation    = Int32.Parse(reader["IdEvaluation"].ToString());
                Vendor.NameEvaluation  = reader["NameEvaluation"].ToString();
                Vendor.Code            = reader["Code"].ToString();
                Vendor.Corporation     = reader["Corporation"].ToString();
                Vendor.Capacity        = Decimal.Parse(reader["Capacity"].ToString());
                Vendor.Representative  = reader["Representative"].ToString();
                Vendor.NumberEmployees = Int32.Parse(reader["NumberEmployees"].ToString());
                Vendor.Situation       = reader["Situation"].ToString();
                Vendor.FlagState       = Boolean.Parse(reader["FlagState"].ToString());
                Vendorlist.Add(Vendor);
            }
            reader.Close();
            reader.Dispose();
            return(Vendorlist);
        }
コード例 #11
0
        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);
            }
        }