public StyleBE Selecciona(int IdStyle)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Style_Selecciona");

            db.AddInParameter(dbCommand, "pIdStyle", DbType.Int32, IdStyle);

            IDataReader reader = db.ExecuteReader(dbCommand);
            StyleBE     Style  = null;

            while (reader.Read())
            {
                Style                    = new StyleBE();
                Style.IdStyle            = Int32.Parse(reader["IdStyle"].ToString());
                Style.IdCompany          = Int32.Parse(reader["IdCompany"].ToString());
                Style.IdClient           = Int32.Parse(reader["IdClient"].ToString());
                Style.NameClient         = reader["NameClient"].ToString();
                Style.NameStyle          = reader["NameStyle"].ToString();
                Style.RevenueDate        = DateTime.Parse(reader["RevenueDate"].ToString());
                Style.Description        = reader["Description"].ToString();
                Style.Item               = reader["Item"].ToString();
                Style.IdClientDepartment = Int32.Parse(reader["IdClientDepartment"].ToString());
                Style.MameDivision       = reader["NameDivision"].ToString();
                Style.IdMediaUnit        = Int32.Parse(reader["IdMediaUnit"].ToString());
                Style.NameMediaUnit      = reader["NameMediaUnit"].ToString();
                Style.Situation          = reader["Situation"].ToString();
                Style.FlagState          = Boolean.Parse(reader["FlagState"].ToString());
            }
            reader.Close();
            reader.Dispose();
            return(Style);
        }
        private void frmRegStyleEdit_Load(object sender, EventArgs e)
        {
            BSUtils.LoaderLook(cboClient, new ClientBL().ListaTodosActivo(Parametros.intEmpresaId), "NameClient", "IdClient", true);
            cboClient.EditValue    = IdClient;
            deRevenueDate.DateTime = DateTime.Now;
            BSUtils.LoaderLook(cboDivision, new ClientDepartmentBL().ListaTodosActivo(IdClient), "NameDivision", "IdClientDepartment", true);
            BSUtils.LoaderLook(cboMediaUnit, new MediaUnitBL().ListaTodosActivo(Parametros.intEmpresaId), "NameMediaUnit", "IdMediaUnit", true);
            cboMediaUnit.EditValue = 1;

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

                StyleBE objE_Style = new StyleBE();

                objE_Style = new StyleBL().Selecciona(IdStyle);
                if (objE_Style != null)
                {
                    cboClient.EditValue    = objE_Style.IdClient;
                    txtNameStyle.Text      = objE_Style.NameStyle;
                    deRevenueDate.DateTime = objE_Style.RevenueDate;
                    txtDescription.Text    = objE_Style.Description;
                    txtItem.Text           = objE_Style.Item;
                    cboDivision.EditValue  = objE_Style.IdClientDepartment;
                    cboMediaUnit.EditValue = objE_Style.IdMediaUnit;
                }
            }

            txtNameStyle.Focus();
        }
        public void InicializarModificar()
        {
            if (gvStyle.RowCount > 0)
            {
                StyleBE objStyle = new StyleBE();
                objStyle.IdCompany = int.Parse(gvStyle.GetFocusedRowCellValue("IdCompany").ToString());
                objStyle.IdClient  = int.Parse(gvStyle.GetFocusedRowCellValue("IdClient").ToString());
                objStyle.IdStyle   = int.Parse(gvStyle.GetFocusedRowCellValue("IdStyle").ToString());

                frmRegStyleEdit objRegStyleEdit = new frmRegStyleEdit();
                objRegStyleEdit.pOperacion = frmRegStyleEdit.Operacion.Modificar;


                objRegStyleEdit.IdClient      = objStyle.IdClient;
                objRegStyleEdit.IdStyle       = objStyle.IdStyle;
                objRegStyleEdit.pStyleBE      = objStyle;
                objRegStyleEdit.StartPosition = FormStartPosition.CenterParent;
                objRegStyleEdit.ShowDialog();

                Cargar();
            }
            else
            {
                MessageBox.Show("Edist");
            }
        }
Example #4
0
 public void Elimina(StyleBE pItem)
 {
     try
     {
         StyleDL Style = new StyleDL();
         Style.Elimina(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #5
0
 public void Actualiza(StyleBE pItem)
 {
     try
     {
         StyleDL Style = new StyleDL();
         Style.Actualiza(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #6
0
 public void Inserta(StyleBE pItem)
 {
     try
     {
         StyleDL Style = new StyleDL();
         Style.Inserta(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #7
0
 public StyleBE Selecciona(int IdStyle)
 {
     try
     {
         StyleDL Style  = new StyleDL();
         StyleBE objEmp = Style.Selecciona(IdStyle);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
        public void Elimina(StyleBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Style_Elimina");

            db.AddInParameter(dbCommand, "pIdStyle", DbType.Int32, pItem.IdStyle);
            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(StyleBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Style_Actualiza");

            db.AddInParameter(dbCommand, "pIdStyle", DbType.Int32, pItem.IdStyle);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pIdClient", DbType.Int32, pItem.IdClient);
            db.AddInParameter(dbCommand, "pNameStyle", DbType.String, pItem.NameStyle);
            db.AddInParameter(dbCommand, "pRevenueDate", DbType.DateTime, pItem.RevenueDate);
            db.AddInParameter(dbCommand, "pDescription", DbType.String, pItem.Description);
            db.AddInParameter(dbCommand, "pItem", DbType.String, pItem.Item);
            db.AddInParameter(dbCommand, "pIdClientDepartment", DbType.Int32, pItem.IdClientDepartment);
            db.AddInParameter(dbCommand, "pIdMediaUnit", DbType.Int32, pItem.IdMediaUnit);
            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);
        }
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (!ValidarIngreso())
                {
                    StyleBL objBL_Style = new StyleBL();
                    StyleBE objStyle    = new StyleBE();

                    objStyle.IdStyle            = IdStyle;
                    objStyle.IdClient           = IdClient;
                    objStyle.NameStyle          = txtNameStyle.Text;
                    objStyle.RevenueDate        = Convert.ToDateTime(deRevenueDate.EditValue);
                    objStyle.Description        = txtDescription.Text;
                    objStyle.Item               = txtItem.Text;
                    objStyle.IdClientDepartment = Convert.ToInt32(cboDivision.EditValue);
                    objStyle.IdMediaUnit        = Convert.ToInt32(cboMediaUnit.EditValue);
                    objStyle.FlagState          = true;
                    objStyle.Login              = Parametros.strUsuarioLogin;
                    objStyle.Machine            = WindowsIdentity.GetCurrent().Name.ToString();
                    objStyle.IdCompany          = Parametros.intEmpresaId;

                    if (pOperacion == Operacion.Nuevo)
                    {
                        objBL_Style.Inserta(objStyle);
                    }
                    else
                    {
                        objBL_Style.Actualiza(objStyle);
                    }

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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())
                    {
                        for (int i = 0; i < gvStyle.SelectedRowsCount; i++)
                        {
                            int row = gvStyle.GetSelectedRows()[i];

                            StyleBE objE_Style = new StyleBE();
                            objE_Style.IdStyle   = int.Parse(gvStyle.GetRowCellValue(row, "IdStyle").ToString());
                            objE_Style.Login     = Parametros.strUsuarioLogin;
                            objE_Style.Machine   = WindowsIdentity.GetCurrent().Name.ToString();
                            objE_Style.IdCompany = Parametros.intEmpresaId;

                            StyleBL objBL_Area = new StyleBL();
                            objBL_Area.Elimina(objE_Style);
                        }


                        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);
            }
        }
        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();
            }
        }