public MDIParentPadre()
 {
     try
     {
         InitializeComponent();
     }
     catch (Exception ex)
     {
         em.sendmail(ex, "Error: F-MDI-001");
     }
 }
示例#2
0
 private void Ingresar_Click(object sender, EventArgs e)
 {
     try
     {
         MDIParentPadre.Usuario  = textBox_Usuario.Text;
         MDIParentPadre.Password = textBox_Pass.Text;
     }
     catch (Exception ex)
     {
         em.sendmail(ex, "Error: F-LO1-001");
     }
 }
        private void cargoVendedores()
        {
            try
            {
                // Me conecto
                SqlCeConnection  conexion    = new SqlCeConnection(MDIParentPadre.st_conexion);
                DataSet          sgdbDataSet = new DataSet();
                string           sql         = "SELECT id_usuario, nombre, apellido FROM data_usuarios WHERE usertype='Vendedor' ORDER BY id_usuario DESC";
                SqlCeDataAdapter da          = new SqlCeDataAdapter(sql, conexion);

                da.Fill(sgdbDataSet, "data_usuarios");
                int rowsCount = sgdbDataSet.Tables["data_usuarios"].Rows.Count;

                Dictionary <string, string> Items = new Dictionary <string, string>();

                // Cargo el primer item vacio
                Items.Add("", "");

                for (int i = 0; i < rowsCount; i++)
                {
                    DataRow dRow = sgdbDataSet.Tables["data_usuarios"].Rows[i];

                    Items.Add(dRow.ItemArray.GetValue(0).ToString(), dRow.ItemArray.GetValue(1).ToString() + "  " + dRow.ItemArray.GetValue(2).ToString());
                }

                this.comboBox_C_Vendedor.DataSource    = new BindingSource(Items, null);
                this.comboBox_C_Vendedor.DisplayMember = "Value";
                this.comboBox_C_Vendedor.ValueMember   = "Key";

                // Get combobox selection (in handler)
                //string value = ((KeyValuePair<string, string>)this.comboBox_C_Vendedor.SelectedItem).Value;

                conexion.Close();
            }
            catch (Exception ex)
            {
                em.sendmail(ex, "Error: F-CA0-003");
            }
        }
 public void cambio_pictureBox(string picPath)
 {
     try
     {
         if (picPath != "")
         {
             this.pictureBox_I_Imagen.Image = Image.FromFile(picPath);
         }
     }
     catch (Exception ex)
     {
         em.sendmail(ex, "Error: F-FA2-001");
     }
 }
        public static bool backupdata(string tipo) //datos o config
        {
            try
            {
                string[] AppArray = Application.ExecutablePath.Split('\\');
                string   ExeFile  = AppArray[AppArray.Count() - 1];

                DirectoryInfo backupdata = new DirectoryInfo(Environment.CurrentDirectory + @"\backupdata\");

                string[] DateArray = DateTime.Now.ToShortDateString().Split('/');

                string DateTimeHora = DateTime.Now.Hour.ToString();
                string DateTimeMin  = DateTime.Now.Minute.ToString();
                string DateTimeSeg  = DateTime.Now.Second.ToString();

                string DateTimeNow = DateArray[2] + "-" + DateArray[1] + "-" + DateArray[0] + "-" + DateTimeHora + "-" + DateTimeMin + "-" + DateTimeSeg;
                if (!backupdata.Exists)
                {
                    backupdata.Create(); // creo el directorio ARTICULOS
                }

                if (tipo == "datos")
                {
                    //busco archivo y lo salvo sgdb.sdf
                    File.Copy(Environment.CurrentDirectory + @"\sgdb.sdf", Environment.CurrentDirectory + @"\backupdata\" + DateTimeNow + @".sdf");
                    return(true);
                }
                else
                {
                    if (tipo == "config")
                    {
                        //busco archivo y lo salvo App.config
                        File.Copy(Environment.CurrentDirectory + @"\" + ExeFile + @".config", Environment.CurrentDirectory + @"\backupdata\" + DateTimeNow + @".config");
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                enviamail em = new enviamail(); // Porque el metodo es publico
                em.sendmail(ex, "Error: F-MDI-003");
                return(false);
            }
        }
        private void button_A_Guardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.textBox_A_Nombre.Text == "" || this.textBox_A_Apellido.Text == "" || this.textBox_A_Usuario.Text == "" || this.textBox_A_Clave.Text == "" || this.textBox_A_Clave2.Text == "" || this.comboBox_A_Nivel.Text == "" || this.textBox_A_Telefono.Text == "" || this.textBox_A_Celular.Text == "")
                {
                    MessageBox.Show("ATENCION: Debe conpletar todos los casilleros marcados con (*)", "Error: F-US1-002", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (this.textBox_A_Clave.Text == this.textBox_A_Clave2.Text)
                    {
                        SqlCeConnection conexion = new SqlCeConnection(MDIParentPadre.st_conexion);
                        string          sql      = "INSERT INTO data_usuarios (nombre,apellido,login,password,usertype,tel_casa,tel_cel) VALUES ('" + this.textBox_A_Nombre.Text +
                                                   "', '" + this.textBox_A_Apellido.Text +
                                                   "', '" + this.textBox_A_Usuario.Text +
                                                   "', '" + this.textBox_A_Clave.Text +
                                                   "', '" + this.comboBox_A_Nivel.Text +
                                                   "', '" + this.textBox_A_Telefono.Text +
                                                   "', '" + this.textBox_A_Celular.Text +
                                                   "')";
                        SqlCeCommand cmd = new SqlCeCommand(sql, conexion);
                        cmd.Connection.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();

                        MessageBox.Show("El usuario se ingreso correctamente.");
                        Limpiar_Formulario_Agregar();
                    }
                    else
                    {
                        MessageBox.Show("ATENCION: La verificación de la clave es incorrecta", "Error: F-US1-003", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                em.sendmail(ex, "Error: F-US1-004");
            }
        }
示例#7
0
        private void PopUp_F_Vendedor_Load(object sender, EventArgs e)
        {
            try
            {
                // Me conecto
                SqlCeConnection  conexion    = new SqlCeConnection(MDIParentPadre.st_conexion);
                DataSet          sgdbDataSet = new DataSet();
                SqlCeCommand     cmd         = new SqlCeCommand();
                string           sql         = "SELECT [id_usuario],[nombre],[apellido] FROM data_usuarios WHERE usertype LIKE '%Vendedor%' ORDER BY id_usuario DESC";
                SqlCeDataAdapter da          = new SqlCeDataAdapter(sql, conexion);

                da.Fill(sgdbDataSet, "data_usuarios");

                BindingSource bindingSource = new BindingSource(sgdbDataSet.Tables[0], null);

                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.Columns.Clear();                              //Borro todas las columnas de dataGridView1

                dataGridView1.Columns.Add("VendedorNumero", "Vendedor N°"); //(nombre de la columna,Titulo de la columna)
                dataGridView1.Columns.Add("Nombre", "Nombre");
                dataGridView1.Columns.Add("Apellido", "Apellido");

                //dataGridView1.Columns[0].Width = 110; // ancho de la columna
                //dataGridView1.Columns[1].Width = 300;
                dataGridView1.Columns[0].DataPropertyName = "id_usuario"; //son los campos de la base de datos
                dataGridView1.Columns[1].DataPropertyName = "nombre";
                dataGridView1.Columns[2].DataPropertyName = "apellido";

                dataGridView1.DataSource = bindingSource;
                //bindingNavigator1.BindingSource = bindingSource;
                conexion.Close();
            }
            catch (Exception ex)
            {
                em.sendmail(ex, "Error: F-VE1-001");
            }
        }
示例#8
0
 private void buscoUltimoID()
 {
     try
     {
         // Me conecto
         SqlCeConnection  conexion    = new SqlCeConnection(MDIParentPadre.st_conexion);
         DataSet          sgdbDataSet = new DataSet();
         SqlCeCommand     cmd         = new SqlCeCommand();
         string           sql         = "SELECT id_cp FROM cliente_proveedor ORDER BY id_cp DESC";
         SqlCeDataAdapter da          = new SqlCeDataAdapter(sql, conexion);
         da.Fill(sgdbDataSet, "cliente_proveedor");
         DataRow dRow = sgdbDataSet.Tables["cliente_proveedor"].Rows[0];
         this.textBox_A_ID.Text = (Convert.ToInt32(dRow.ItemArray.GetValue(0)) + 1).ToString();
     }
     catch (Exception ex)
     {
         em.sendmail(ex, "Error: F-CL1-000");
     }
 }
示例#9
0
        //private DataGridViewCheckBoxColumn facturar;

        private void listoFacturas()
        {
            try
            {
                string buscarEn = "";

                if (toolStripComboBox_buscarEn.SelectedItem.ToString() != "")
                {
                    buscarEn = toolStripComboBox_buscarEn.SelectedItem.ToString();
                }
                else
                {
                    buscarEn = "Facturado A,B,C,T";
                }

                string busco = toolStripTextBox_Buscar.Text;
                // Me conecto
                SqlCeConnection conexion    = new SqlCeConnection(MDIParentPadre.st_conexion);
                DataSet         sgdbDataSet = new DataSet();

                if (this.toolStripTextBox_Buscar.Text != "")
                {
                    string sql = "";
                    if (buscarEn == "Facturado A,B,C,T")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('A') OR upper(f_tipo) = upper('B') OR  upper(f_tipo) = upper('C') OR upper(f_tipo) = upper('Ticket'))";
                    }
                    if (buscarEn == "Cuenta Corriente")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('CC'))";
                    }
                    if (buscarEn == "NC")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('NC'))";
                    }
                    if (buscarEn == "NP")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('NC'))";
                    }
                    if (buscarEn == "MovStock")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('MovStock'))";
                    }
                    if (buscarEn == "Remitos")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('Remito'))";
                    }
                    if (buscarEn == "Presupuesto")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('Presupuesto'))";
                    }
                    if (buscarEn == "Guardado")
                    {
                        sql = "SELECT * FROM facturas WHERE (upper(f_numero) LIKE upper('%" + busco + "%') OR upper(f_fecha) LIKE upper('%" + busco + "%') OR upper(f_c_razon_social) LIKE upper('%" + busco + "%')) AND (upper(f_tipo) = upper('Guardado'))";
                    }

                    SqlCeDataAdapter da = new SqlCeDataAdapter(sql, conexion);
                    da.Fill(sgdbDataSet, "facturas");
                    int rowsCount = sgdbDataSet.Tables["facturas"].Rows.Count;

                    if (rowsCount > 0)
                    {
                        this.dataGridView.AutoGenerateColumns = false;  // Sin esta linea me llena el datagrid con todo lo que tiene la tabla o las tablas

                        this.dataGridView.Columns[1].DataPropertyName = "f_tipo";
                        this.dataGridView.Columns[2].DataPropertyName = "f_punto_venta";
                        this.dataGridView.Columns[3].DataPropertyName = "f_numero"; //son los campos de la base de datos
                        this.dataGridView.Columns[4].DataPropertyName = "f_fecha";
                        this.dataGridView.Columns[5].DataPropertyName = "fi_total";
                        this.dataGridView.Columns[6].DataPropertyName = "f_c_codigo";
                        this.dataGridView.Columns[7].DataPropertyName = "f_c_razon_social";
                        this.dataGridView.Columns[8].DataPropertyName = "f_c_descuento";

                        /*
                         * if (buscarEn == "Facturado A,B,C,T")
                         * {
                         *  DataGridViewCheckBoxColumn facturar = new DataGridViewCheckBoxColumn();
                         *  {
                         *      facturar.HeaderText = "Facturar";
                         *      facturar.Name = "facturar";
                         *      facturar.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
                         *      facturar.ReadOnly = true;
                         *      facturar.Width = 52;
                         *      facturar.CellTemplate = cbFacturar;
                         *  }
                         *
                         *  this.dataGridView.Columns.Insert(9, facturar);
                         * }
                         * else
                         * {
                         *  this.dataGridView.Columns.RemoveAt(9);
                         * }
                         * this.dataGridView.Columns[9].DataPropertyName = "f_status";
                         *
                         * //dataGridView.Columns[9].CellTemplate = new DataGridViewCheckBoxCell();
                         * //dataGridView.Columns[9].CellTemplate.ReadOnly = false;
                         *
                         *
                         * if (buscarEn == "Facturado A,B,C,T" || buscarEn == "Nota de Credito" || buscarEn == "Movimiento Stock")
                         * {
                         *  this.dataGridView.Columns[9].Visible = false;
                         * }
                         * else
                         * {
                         *  this.dataGridView.Columns[9].Visible = true;
                         *  this.dataGridView.Columns[9].DataPropertyName = "f_status";
                         * }
                         */
                        BindingSource bS = new BindingSource(sgdbDataSet.Tables["facturas"], null);
                        dataGridView.DataSource         = bS;
                        bindingNavigator1.BindingSource = bS;
                    }
                }
                else
                {
                    this.dataGridView.DataSource = null;
                    //MessageBox.Show("Debe seleccionar un método de busqueda desde la lista desplegable.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                if (dataGridView.Rows.Count > 0)
                {
                    this.toolStripButton_Eliminar.Enabled = true;
                }
                else
                {
                    this.toolStripButton_Eliminar.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                em.sendmail(ex, "Error: F-FA3-001");
            }
        }
        private void creoBotones()
        {
            try
            {
                /*
                 * EJEMPLO DE COMO AGREGAR UN ELEMENTO
                 *
                 * this.button1 = new System.Windows.Forms.Button();
                 * this.SuspendLayout();
                 * //
                 * // button1
                 * //
                 * this.button1.BackColor = System.Drawing.Color.PaleTurquoise;
                 * this.button1.Location = new System.Drawing.Point(12, 32);
                 * this.button1.Name = "button1";
                 * this.button1.Size = new System.Drawing.Size(75, 75);
                 * this.button1.TabIndex = 0;
                 * this.button1.Text = "Caramelos $0.25";
                 * this.button1.UseVisualStyleBackColor = false;
                 *
                 * this.Controls.Add(this.button1);
                 */
                // Me conecto
                SqlCeConnection  conexion = new SqlCeConnection(MDIParentPadre.st_conexion);
                DataSet          ds       = new DataSet();
                string           sql      = "SELECT codigo_barra, codigo_interno, descripcion, unidad, precio_venta1 FROM articulos WHERE orden!='' ORDER BY orden";
                SqlCeDataAdapter da       = new SqlCeDataAdapter(sql, conexion);

                da.Fill(ds, "articulos");

                int i;
                int c        = 1;
                int cols     = 80;
                int rows     = 80;
                int cantidad = ds.Tables["articulos"].Rows.Count;
                MessageBox.Show(cantidad.ToString());

                for (i = 0; i < cantidad && i < 30; i++)
                {
                    if (c == 10)
                    {
                        cols = 80; rows = rows + 80; c = 1;
                    }
                    else
                    {
                        cols = c * 80;
                    }

                    DataRow dRow = ds.Tables["articulos"].Rows[i];

                    this.button1 = new System.Windows.Forms.Button();
                    this.SuspendLayout();
                    this.button1.BackColor = System.Drawing.Color.PaleTurquoise;
                    this.button1.Location  = new System.Drawing.Point((15 + cols), (15 + rows));
                    this.button1.Name      = "button" + i;
                    this.button1.Size      = new System.Drawing.Size(75, 75);
                    this.button1.TabIndex  = 0;
                    this.button1.Text      = dRow.ItemArray.GetValue(2).ToString() + "\n\t(" + dRow.ItemArray.GetValue(3).ToString() + "x" + dRow.ItemArray.GetValue(4).ToString() + ")";
                    this.button1.UseVisualStyleBackColor = false;

                    this.Controls.Add(this.button1);

                    c++;
                }



                /*
                 * if (dRow.ItemArray.GetValue(14).ToString() != "")
                 * {
                 *  this.pictureBox_E_Imagen.Image = Image.FromFile(dRow.ItemArray.GetValue(14).ToString());
                 * }
                 * else this.pictureBox_E_Imagen.Image = null;
                 */
                conexion.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                em.sendmail(ex, "Error: F-FB1-001");
            }
        }