private void datosgeneral(String sqldata)
        {
            var conex = new ConexionDA();
            var dt = new DataTable();

            using (var cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (var cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = sqldata;
                    try
                    {
                        cnx.Open();
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                gridgeneral.AutoGenerateColumns = true;
                                gridgeneral.DataSource = dt;
                            }

                            if (nameform == "color")
                            {
                                if (VariablesPublicas.Moduloid == "0500")
                                {
                                    foreach (DataGridViewRow fila in gridgeneral.Rows)
                                    {
                                        var xproductidold = string.Empty;

                                        if (gridgeneral.ColumnCount >= 4)
                                        {
                                            if (gridgeneral.Columns[4].HeaderText == "productidold")
                                            {
                                                xproductidold = Convert.ToString(gridgeneral.Rows[fila.Index].Cells["productidold"].Value);

                                                if (xproductidold.Trim() != "0")
                                                {
                                                    gridgeneral.Rows[fila.Index].DefaultCellStyle.BackColor = Color.MediumSeaGreen;
                                                    gridgeneral.Rows[fila.Index].DefaultCellStyle.ForeColor = Color.White;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void datosgeneral(String sqldata)
        {
            ConexionDA conex = new ConexionDA();
            DataSet ds = new DataSet();

            using (SqlConnection cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (SqlCommand cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = sqldata;
                    }
                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);

                            if (ds.Tables[0].Rows.Count > 0 && gridgeneral.RowCount > 0)
                            {
                                this.gridgeneral.Focus();
                                this.gridgeneral.BeginEdit(false);
                            }
                            this.gridgeneral.AutoGenerateColumns = true;
                            gridgeneral.DataSource = ds.Tables[0];
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
 private DataSet Consultas(String Query)
 {
     var conex = new ConexionDA();
     using (var cnx = new SqlConnection(conex.empConexion(EmpresaID)))
     {
         using (var cmd = new SqlCommand("gspHelpSQL", cnx))
         {
             var ds = new DataSet();
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = Query;
             try
             {
                 cnx.Open();
                 using (var da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private DataTable ProdMov(String Query)
        {
            var conex = new ConexionDA();
            var dt = new DataTable();
            using (var cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (var cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = Query;

                    try
                    {
                        cnx.Open();
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);
                            return dt;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
        private void datosgeneral(String sqldata)
        {
            var conex = new ConexionDA();
            var dt = new DataTable();

            using (var cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (var cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = sqldata;
                    try
                    {
                        cnx.Open();
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                gridgeneral.AutoGenerateColumns = true;
                                gridgeneral.DataSource = dt;
                            }

                            if (VariablesPublicas.Moduloid == "0500")
                            {
                                foreach (DataGridViewRow fila in gridgeneral.Rows)
                                {
                                    var  x1 = Convert.ToString(gridgeneral.Rows[fila.Index].Cells["productid"].Value);
                                    var tipodoc = "VS";
                                    var xxData = "SELECT top 1 * from tb_sm_movimientosdet where tipodoc = '" + tipodoc + "' and productid = '" + x1 + "' ORDER BY fechdoc DESC";

                                    var dt2 = new DataTable();
                                    dt2 = ProdMov(xxData);

                                    if (dt2.Rows.Count > 0)
                                    {
                                        var x2 = dt2.Rows[0]["productid"].ToString();

                                        if (x1 == x2)
                                        {
                                            gridgeneral.Rows[fila.Index].DefaultCellStyle.BackColor = Color.MediumSeaGreen;
                                            gridgeneral.Rows[fila.Index].DefaultCellStyle.ForeColor = Color.White;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private DataTable DatosSQL(String query)
        {
            var conex = new ConexionDA();
            var dt = new DataTable();

            using (var cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (var cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = query;

                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);
                        }
                        return dt;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                        //MessageBox.Show(ex.Message, "Error");
                    }
                }
            }
        }
        private void datosgeneral(String sqldata)
        {
            var conex = new ConexionDA();
            var dt = new DataTable();

            using (var cnx = new SqlConnection(conex.empConexion(VariablesPublicas.EmpresaID)))
            {
                using (var cmd = new SqlCommand("gspHelpSQL", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@sqlquery", SqlDbType.VarChar).Value = sqldata;
                    try
                    {
                        cnx.Open();
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                gridgeneral.AutoGenerateColumns = true;
                                gridgeneral.DataSource = dt;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }