Пример #1
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())
                    {
                        MediaUnitBE objE_MediaUnit = new MediaUnitBE();
                        objE_MediaUnit.IdMediaUnit = int.Parse(gvMediaUnit.GetFocusedRowCellValue("IdMediaUnit").ToString());
                        objE_MediaUnit.Login       = Parametros.strUsuarioLogin;
                        objE_MediaUnit.Machine     = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_MediaUnit.IdCompany   = Parametros.intEmpresaId;

                        MediaUnitBL objBL_MediaUnit = new MediaUnitBL();
                        objBL_MediaUnit.Elimina(objE_MediaUnit);
                        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);
            }
        }
        public List <MediaUnitBE> ListaTodosActivo(int IdCompany)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_MediaUnit_ListaTodosActivo");

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

            IDataReader        reader        = db.ExecuteReader(dbCommand);
            List <MediaUnitBE> MediaUnitlist = new List <MediaUnitBE>();
            MediaUnitBE        MediaUnit;

            while (reader.Read())
            {
                MediaUnit               = new MediaUnitBE();
                MediaUnit.IdMediaUnit   = Int32.Parse(reader["idMediaUnit"].ToString());
                MediaUnit.IdCompany     = Int32.Parse(reader["IdCompany"].ToString());
                MediaUnit.Abbreviate    = reader["Abbreviate"].ToString();
                MediaUnit.NameMediaUnit = reader["NameMediaUnit"].ToString();
                MediaUnit.FlagState     = Boolean.Parse(reader["FlagState"].ToString());
                MediaUnitlist.Add(MediaUnit);
            }
            reader.Close();
            reader.Dispose();
            return(MediaUnitlist);
        }
Пример #3
0
 public void Elimina(MediaUnitBE pItem)
 {
     try
     {
         MediaUnitDL MediaUnit = new MediaUnitDL();
         MediaUnit.Elimina(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Пример #4
0
 public void Actualiza(MediaUnitBE pItem)
 {
     try
     {
         MediaUnitDL MediaUnit = new MediaUnitDL();
         MediaUnit.Actualiza(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Пример #5
0
 public MediaUnitBE SeleccionaAbreviatura(int IdCompany, string Abbreviate)
 {
     try
     {
         MediaUnitDL MediaUnit = new MediaUnitDL();
         MediaUnitBE objEmp    = MediaUnit.SeleccionaAbreviatura(IdCompany, Abbreviate);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Пример #6
0
 public MediaUnitBE SeleccionaDescripcion(int IdCompany, string NameMediaUnit)
 {
     try
     {
         MediaUnitDL MediaUnit = new MediaUnitDL();
         MediaUnitBE objEmp    = MediaUnit.SeleccionaDescripcion(IdCompany, NameMediaUnit);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Пример #7
0
 public MediaUnitBE Selecciona(int IdMediaUnit)
 {
     try
     {
         MediaUnitDL MediaUnit = new MediaUnitDL();
         MediaUnitBE objEmp    = MediaUnit.Selecciona(IdMediaUnit);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
        public void Elimina(MediaUnitBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_MediaUnit_Elimina");

            db.AddInParameter(dbCommand, "pIdMediaUnit", DbType.Int32, pItem.IdMediaUnit);
            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(MediaUnitBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_MediaUnit_Actualiza");

            db.AddInParameter(dbCommand, "pIdMediaUnit", DbType.Int32, pItem.IdMediaUnit);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pAbbreviate", DbType.String, pItem.Abbreviate);
            db.AddInParameter(dbCommand, "pNameMediaUnit", DbType.String, pItem.NameMediaUnit);
            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);
        }
Пример #10
0
        private void frmManMediaUnitEdit_Load(object sender, EventArgs e)
        {
            if (pOperacion == Operacion.Nuevo)
            {
                this.Text = "MediaUnit - New";
            }
            else if (pOperacion == Operacion.Modificar)
            {
                this.Text = "MediaUnit - Update";
                MediaUnitBE objE_MediaUnit = null;
                objE_MediaUnit = new MediaUnitBL().Selecciona(IdMediaUnit);
                if (objE_MediaUnit != null)
                {
                    txtAbbreviate.Text  = objE_MediaUnit.Abbreviate;
                    txtDescripcion.Text = objE_MediaUnit.NameMediaUnit.Trim();
                }
            }

            txtAbbreviate.Select();
        }
Пример #11
0
        public void InicializarModificar()
        {
            if (gvMediaUnit.RowCount > 0)
            {
                MediaUnitBE objMediaUnit = new MediaUnitBE();

                objMediaUnit.IdMediaUnit = int.Parse(gvMediaUnit.GetFocusedRowCellValue("IdMediaUnit").ToString());

                frmManMediaUnitEdit objManMediaUnitEdit = new frmManMediaUnitEdit();
                objManMediaUnitEdit.pOperacion    = frmManMediaUnitEdit.Operacion.Modificar;
                objManMediaUnitEdit.IdMediaUnit   = objMediaUnit.IdMediaUnit;
                objManMediaUnitEdit.pMediaUnitBE  = objMediaUnit;
                objManMediaUnitEdit.StartPosition = FormStartPosition.CenterParent;
                objManMediaUnitEdit.ShowDialog();

                Cargar();
            }
            else
            {
                MessageBox.Show("No se pudo editar");
            }
        }
Пример #12
0
        public MediaUnitBE Selecciona(int IdMediaUnit)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_MediaUnit_Selecciona");

            db.AddInParameter(dbCommand, "pidMediaUnit", DbType.Int32, IdMediaUnit);

            IDataReader reader    = db.ExecuteReader(dbCommand);
            MediaUnitBE MediaUnit = null;

            while (reader.Read())
            {
                MediaUnit               = new MediaUnitBE();
                MediaUnit.IdMediaUnit   = Int32.Parse(reader["idMediaUnit"].ToString());
                MediaUnit.IdCompany     = Int32.Parse(reader["IdCompany"].ToString());
                MediaUnit.Abbreviate    = reader["Abbreviate"].ToString();
                MediaUnit.NameMediaUnit = reader["NameMediaUnit"].ToString();
                MediaUnit.FlagState     = Boolean.Parse(reader["FlagState"].ToString());
            }
            reader.Close();
            reader.Dispose();
            return(MediaUnit);
        }
Пример #13
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (!ValidarIngreso())
                {
                    MediaUnitBL objBL_MediaUnit = new MediaUnitBL();
                    MediaUnitBE objMediaUnit    = new MediaUnitBE();

                    objMediaUnit.IdMediaUnit   = IdMediaUnit;
                    objMediaUnit.Abbreviate    = txtAbbreviate.Text;
                    objMediaUnit.NameMediaUnit = txtDescripcion.Text;
                    objMediaUnit.FlagState     = true;
                    objMediaUnit.Login         = Parametros.strUsuarioLogin;
                    objMediaUnit.Machine       = WindowsIdentity.GetCurrent().Name.ToString();
                    objMediaUnit.IdCompany     = Parametros.intEmpresaId;

                    if (pOperacion == Operacion.Nuevo)
                    {
                        objBL_MediaUnit.Inserta(objMediaUnit);
                    }
                    else
                    {
                        objBL_MediaUnit.Actualiza(objMediaUnit);
                    }

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #14
0
        private void ImportarExcel()
        {
            if (strFleExcel == "")
            {
                return;
            }

            Excel._Application xlApp;
            Excel._Workbook    xlLibro;
            Excel._Worksheet   xlHoja;
            Excel.Sheets       xlHojas;
            xlApp   = new Excel.Application();
            xlLibro = xlApp.Workbooks.Open(strFleExcel, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            xlHojas = xlLibro.Sheets;
            xlHoja  = (Excel._Worksheet)xlHojas[1];
            int Secuencia = 2;
            int _row      = 2;
            int _totRow   = 2;

            try
            {
                List <StyleBE> lstStyle = new List <StyleBE>();

                while (FuncionBase.IsNumeric((string)xlHoja.get_Range("A" + _row, Missing.Value).Text.ToString().Trim()))
                {
                    //Declaracion de variables

                    int      IdCompany             = 0;
                    int      intIdClient           = 0;
                    string   strNameClient         = "";
                    string   strNameStyle          = "";
                    DateTime RevenueDate           = new DateTime(2010, 1, 1);
                    string   strDescription        = "";
                    int      intIdClientDepartment = 0;
                    string   strNameDivision       = "";
                    int      IdMediaUnit           = 0;
                    string   strAbbreviate         = "";

                    strNameClient = (string)xlHoja.get_Range("B" + _row, Missing.Value).Text.ToString().Trim();
                    ClientBE objE_Client = null;
                    objE_Client = new ClientBL().SeleccionaDescripcion(Parametros.intEmpresaId, strNameClient);
                    if (objE_Client != null)
                    {
                        intIdClient     = objE_Client.IdClient;
                        strNameStyle    = (string)xlHoja.get_Range("C" + _row, Missing.Value).Text.ToString().Trim();
                        RevenueDate     = Convert.ToDateTime(xlHoja.get_Range("D" + _row, Missing.Value).Text.ToString().Trim());
                        strDescription  = (string)xlHoja.get_Range("E" + _row, Missing.Value).Text.ToString().Trim();
                        strNameDivision = (string)xlHoja.get_Range("F" + _row, Missing.Value).Text.ToString().Trim();
                        ClientDepartmentBE objE_ClientDepartment = null;
                        objE_ClientDepartment = new ClientDepartmentBL().SeleccionaDescripcion(intIdClient, strNameDivision);
                        if (objE_ClientDepartment != null)
                        {
                            intIdClientDepartment = objE_ClientDepartment.IdClientDepartment;
                        }
                        else
                        {
                            XtraMessageBox.Show("N° Secuencia : " + Secuencia.ToString() + "\n Division: " + strNameDivision, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            xlLibro.Close(false, Missing.Value, Missing.Value);
                            xlApp.Quit();
                            this.Dispose();
                            this.Close();
                        }

                        strAbbreviate = (string)xlHoja.get_Range("G" + _row, Missing.Value).Text.ToString().Trim();

                        MediaUnitBE objE_MediaUnit = null;
                        objE_MediaUnit = new MediaUnitBL().SeleccionaAbreviatura(Parametros.intEmpresaId, strAbbreviate);
                        if (objE_MediaUnit != null)
                        {
                            IdMediaUnit = objE_MediaUnit.IdMediaUnit;
                        }
                        else
                        {
                            XtraMessageBox.Show("N° Secuencia : " + Secuencia.ToString() + "\n Media Unit: " + strAbbreviate, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            xlLibro.Close(false, Missing.Value, Missing.Value);
                            xlApp.Quit();
                            this.Dispose();
                            this.Close();
                        }

                        StyleBE objE_Style = new StyleBE();
                        objE_Style.IdStyle            = 0;
                        objE_Style.IdCompany          = Parametros.intEmpresaId;
                        objE_Style.IdClient           = intIdClient;
                        objE_Style.NameStyle          = strNameStyle;
                        objE_Style.RevenueDate        = RevenueDate;
                        objE_Style.Description        = strDescription;
                        objE_Style.IdClientDepartment = intIdClientDepartment;
                        objE_Style.IdMediaUnit        = IdMediaUnit;
                        objE_Style.FlagState          = true;
                        objE_Style.Login   = Parametros.strUsuarioLogin;
                        objE_Style.Machine = WindowsIdentity.GetCurrent().Name.ToString();

                        lstStyle.Add(objE_Style);
                    }

                    Application.DoEvents();
                    _row++;
                    Secuencia++;
                }

                StyleBL objBL_Style = new StyleBL();
                objBL_Style.InsertaMasivo(lstStyle);
                XtraMessageBox.Show("Los Datos se guardaron conrrectamente.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                xlLibro.Close(false, Missing.Value, Missing.Value);
                xlApp.Quit();
                this.Close();
            }
            catch (Exception ex)
            {
                xlApp.Quit();
                XtraMessageBox.Show(ex.Message + "\n N° Secuencia : " + Secuencia.ToString(), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }