public bool Delete(string empresaid, tb_sys_modulo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbSysModulo_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominioiddes.Trim();
                BE.moduloid = moduloid;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Form_help_requerimiento();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA PRODUCTOS >>";
                        frmayuda.sqlquery = "SELECT tb1.productid, tb1.productname, tb2.stock, tb1.unmedenvase as unmedenvase ,tb2.costoultimo  FROM tb_" + modd + "_productos AS tb1 ";
                        frmayuda.sqlinner = "inner join tb_" + modd + "_local_stock as tb2 on tb1.productid = tb2.productid ";
                        frmayuda.sqlwhere = "where ";
                        frmayuda.sqland = string.Empty;
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid";
                        frmayuda.returndatos = "0,1,2,3";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProducto;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void data_cbo_moduloiddes()
        {
            try
            {
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                BE.dominioid = "60";
                BE.status = "0";

                var dt = new DataTable();
                dt = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];
                cbo_modulo.DataSource = dt;
                cbo_modulo.ValueMember = "moduloid";
                cbo_modulo.DisplayMember = "moduloname";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio.Trim();
                BE.moduloid = modulo.Trim();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();
                        frmayuda.nameform = string.Empty;
                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA PRODUCTOS >>";
                        frmayuda.sqlquery = "SELECT tb1.productid, tb1.productname,tb2.lineaname,tb3.gruponame FROM tb_" + modd + "_productos AS tb1 ";
                        frmayuda.sqlinner = "inner join tb_" + modd + "_linea as tb2 on tb1.lineaid = tb2.lineaid " +
                                            "inner join tb_" + modd + "_grupo as tb3 on tb1.grupoid = tb3.grupoid";
                        frmayuda.sqlwhere = "where";
                        frmayuda.sqland = string.Empty;
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO", "LINEA", "GRUPO" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid,tb2.lineaname,tb3.gruponame";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProducto;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void AyudaGrupo(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = cbo_almacenes.SelectedValue.ToString();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA GRUPOS >>";
                        frmayuda.sqlquery = " SELECT ctacte, ctactename FROM tb_cliente ";
                        frmayuda.sqlinner = string.Empty;
                        frmayuda.sqlwhere = " where ";
                        frmayuda.sqland = string.Empty;
                        frmayuda.criteriosbusqueda = new string[] { "PROVEEDOR", "CODIGO" };
                        frmayuda.columbusqueda = "ctactename,ctacte";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeGrupo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
 public DataSet GetAll(string empresaid, tb_sys_modulo BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbSysModulo_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@moduloname", SqlDbType.VarChar, 40).Value = BE.moduloname;
                 cmd.Parameters.Add("@moduloshort", SqlDbType.Char, 2).Value = BE.moduloshort;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                 //cmd.Parameters.Add("@fecre", SqlDbType.DateTime).Value = BE.fecre;
                 //cmd.Parameters.Add("@feact", SqlDbType.DateTime).Value = BE.feact;
                 cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                 //cmd.Parameters.Add("@pedAprob", SqlDbType.Bit).Value = BE.pedaprob;
                 //cmd.Parameters.Add("@pedTienda", SqlDbType.Bit).Value = BE.pedtienda;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void AyudaCliente(String lpdescrlike)
        {
            try
            {
                String modd = "";
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.dominioid = dominioid.Text.ToString();
                BE.moduloid = moduloid.Text.ToString();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        Ayudas.Frm_help_general frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql"; //sql,tabla
                        frmayuda.titulo = "<< AYUDA TABLA GRUPOS >>";
                        frmayuda.sqlquery = " SELECT ctacte, ctactename ,nmruc  FROM tb_cliente ";
                        frmayuda.sqlinner = ""; //inner
                        frmayuda.sqlwhere = " where "; //where
                        frmayuda.sqland = "";//and
                        frmayuda.criteriosbusqueda = new string[] { "PROVEEDOR", "CODIGO" };
                        frmayuda.columbusqueda = "ctactename,ctacte";
                        frmayuda.returndatos = "0,1,2";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeCliente;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        private void Ayudasubgrupo(String lpdescrlike)
        {
            try
            {
                String modd = "";
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        Ayudas.Frm_help_general frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql"; //sql,tabla
                        frmayuda.titulo = "<< AYUDA TABLA ARTICULO >>";
                        frmayuda.sqlquery = "SELECT (lineaid + gr.grupoid + subgrupoid) as Codigo,lineaid,gr.grupoid,g.gruponame,subgrupoid,subgruponame,g.ctacte  FROM tb_" + modd + "_subgrupo gr ";

                        if (modd == "sm")
                        {frmayuda.sqlinner = " Inner Join tb_" + modd + "_grupo g on gr.grupoid = g.grupoid and gr.status = '0' ";}
                        else { frmayuda.sqlinner = " Inner Join tb_" + modd + "_grupo g on gr.grupoid = g.grupoid and gr.status = '0' "; }

                        if (lineaid.Text.Trim().Length > 0 && grupoid.Text.Trim().Length > 0)
                        {
                            frmayuda.sqlwhere = "WHERE lineaid = " + lineaid.Text + " and gr.grupoid = " + grupoid.Text + " "; //where
                            frmayuda.sqland = "and";//and
                        }
                        else if (lineaid.Text.Trim().Length > 0)
                        {
                            frmayuda.sqlwhere = "WHERE lineaid = " + lineaid.Text + " "; //where
                            frmayuda.sqland = "and";//and
                        }
                        else if (grupoid.Text.Trim().Length > 0)
                        {
                            frmayuda.sqlwhere = "WHERE gr.grupoid = " + grupoid.Text + " "; //where
                            frmayuda.sqland = "and";//and
                        }
                        else
                        {
                            frmayuda.sqlwhere = "where"; //where
                            frmayuda.sqland = "";//and
                        }

                        frmayuda.criteriosbusqueda = new string[] {"ARTICULO", "CODIGO" };
                        frmayuda.columbusqueda = "subgruponame,lineaid + gr.grupoid + subgrupoid";
                        frmayuda.returndatos = "1,2,4,6";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeSubgrupo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        private void AyudaColor(String lpdescrlike)
        {
            try
            {
                String modd = "";
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();
                        Ayudas.Frm_help_general frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql"; //sql,tabla,all
                        frmayuda.titulo = "Ayuda Color";
                        frmayuda.sqlquery = "select colorid, colorname from tb_" + modd + "_color";
                        frmayuda.sqlinner = ""; //inner
                        frmayuda.sqlwhere = "where"; //where
                        frmayuda.sqland = "";//and
                        frmayuda.criteriosbusqueda = new string[] { "COLOR", "CÓDIGO" };
                        frmayuda.columbusqueda = "colorname,colorid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeColor;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                griddetallemov.CurrentCell = griddetallemov.Rows[griddetallemov.RowCount - 1].Cells["productname"];
                var prod = Convert.ToString(griddetallemov.Rows[griddetallemov.CurrentCell.RowIndex].Cells["productid"].Value);
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();
                        var frmayuda = new Ayudas.Form_help_stockinventario();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< Ayuda Producto Inventariado >>";

                        frmayuda.sqlquery = " select li.productid," +
                                                    " p.productname," +
                                                    " li.stocklibros," +
                                                    " li.stockfisico," +
                                                    " li.diferencia," +
                                                    " li.costopromlibros," +
                                                    " li.costopromfisico " +
                                                    " from tb_" + modd + "_local_stock_inventario li ";
                        frmayuda.sqlinner = " left join tb_" + modd + "_productos p on li.productid = p.productid ";
                        frmayuda.sqlwhere = "where";
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "p.productname,li.productid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProductoRollo;
                        if (prod == string.Empty)
                        {
                            prod = "_";
                        }
                        frmayuda.txt_busqueda.Text = prod;
                        frmayuda.btnbuscar.PerformClick();
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Validamodulo_nuevo()
        {
            if (dominioid.Text.Trim().Length == 2)
            {
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();
                BE.dominioid = dominioid.Text.Trim();
                BE.moduloid = moduloid.Text.Trim();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count == 0)
                {
                    mensaje.Text = "VALIDO";
                    mensaje.ForeColor = Color.Green;
                    form_bloqueado(true);
                    moduloname.Focus();

                    btn_cancelar.Enabled = true;
                    btn_grabar.Enabled = true;
                }
                else
                {
                    mensaje.Text = "YA EXISTE";
                    mensaje.ForeColor = Color.Red;
                    moduloid.Focus();
                }
            }
        }
        private void Ayudasubgrupo(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA ARTICULO >>";
                        frmayuda.sqlquery = "SELECT subgrupoid, subgruponame, lineaid, grupoid FROM tb_me_subgrupo ";
                        frmayuda.sqlinner = string.Empty;
                        if (lineaid.Text.Trim().Length > 0 && grupoid.Text.Trim().Length > 0)
                        {
                            frmayuda.sqlwhere = "where lineaid = " + lineaid.Text + " and grupoid = " + grupoid.Text + " ";
                            frmayuda.sqland = "and";
                        }
                        else
                        {
                            if (lineaid.Text.Trim().Length > 0)
                            {
                                frmayuda.sqlwhere = "where lineaid = " + lineaid.Text + " ";
                                frmayuda.sqland = "and";
                            }
                            else
                            {
                                if (grupoid.Text.Trim().Length > 0)
                                {
                                    frmayuda.sqlwhere = "where grupoid = " + grupoid.Text + " ";
                                    frmayuda.sqland = "and";
                                }
                                else
                                {
                                    frmayuda.sqlwhere = "where";
                                    frmayuda.sqland = string.Empty;
                                }
                            }
                        }
                        frmayuda.criteriosbusqueda = new string[] { "ARTICULO", "CODIGO" };
                        frmayuda.columbusqueda = "subgruponame,subgrupoid";
                        frmayuda.returndatos = "0,2,3";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeSubgrupo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
 private void get_cbo_modulo()
 {
     var BL = new sys_moduloBL();
     var BE = new tb_sys_modulo();
     var dt = new DataTable();
     BE.dominioid = dominio.Trim();
     dt = BL.GetAll(EmpresaID, BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         cbo_moduloides.DataSource = dt;
         cbo_moduloides.ValueMember = "moduloid";
         cbo_moduloides.DisplayMember = "moduloname";
     }
 }
        private void AyudaLinea(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominioiddes;
                BE.moduloid = moduloiddes.SelectedValue.ToString();
                if (moduloiddes.SelectedValue.ToString() == "0000")
                {
                    MessageBox.Show("Seleccione Almacen", "Information");
                    return;
                }

                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA LINEA >>";
                        frmayuda.sqlquery = " SELECT sg.lineaid,li.lineaname "+
                                            " FROM tb_" + modd + "_subgrupo sg " +
                                            " LEFT JOIN tb_" + modd + "_linea li on sg.lineaid = li.lineaid ";
                        frmayuda.sqlinner = string.Empty;
                        frmayuda.sqlwhere = "WHERE sg.subgrupoid = '"+txt_subgrupoid.Text+"' and grupoid = '"+txt_grupoid.Text+"' ";
                        frmayuda.sqland = "AND";
                        frmayuda.criteriosbusqueda = new string[] { "LINEA", "CODIGO" };
                        frmayuda.columbusqueda = "lineaname,lineaid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeLinea;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void Ayudasubgrupo(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = "60";
                BE.moduloid = moduloiddes.SelectedValue.ToString();
                if (moduloiddes.SelectedValue.ToString() == "0000")
                {
                    MessageBox.Show("Seleccione Almacen", "Information");
                    return;
                }
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA ARTICULO >>";
                        frmayuda.sqlquery = "SELECT (lineaid + gr.grupoid + subgrupoid) as Codigo,lineaid,gr.grupoid,g.gruponame,subgrupoid,subgruponame,g.ctacte  FROM tb_" + modd + "_subgrupo gr ";

                        if (modd == "sm")
                        {
                            frmayuda.sqlinner = " Inner Join tb_" + modd + "_grupo g on gr.grupoid = g.grupoid and gr.status = '0' ";
                        }
                        else
                        {
                            frmayuda.sqlinner = " Inner Join tb_" + modd + "_grupo g on gr.grupoid = g.grupoid and gr.status = '0' ";
                        }

                        //if (txt_lineaid.Text.Trim().Length > 0 && txt_grupoid.Text.Trim().Length > 0)
                        //{
                        //    frmayuda.sqlwhere = "where lineaid = " + txt_lineaid.Text + " and g.grupoid = " + txt_grupoid.Text + " ";
                        //    frmayuda.sqland = "and";
                        //}
                        //else
                        //{
                        //    if (txt_lineaid.Text.Trim().Length > 0)
                        //    {
                        //        frmayuda.sqlwhere = "where lineaid = " + txt_lineaid.Text + " ";
                        //        frmayuda.sqland = "and";
                        //    }
                        //    else
                        //    {
                        //        if (txt_grupoid.Text.Trim().Length > 0)
                        //        {
                        //            frmayuda.sqlwhere = "where g.grupoid = " + txt_grupoid.Text + " ";
                        //            frmayuda.sqland = "and";
                        //        }
                        //        else
                        //        {
                                    frmayuda.sqlwhere = "where";
                                    frmayuda.sqland = string.Empty;
                            //    }
                            //}
                        //}
                        frmayuda.criteriosbusqueda = new string[] { "ARTICULO", "CODIGO" };
                        frmayuda.columbusqueda = "subgruponame,subgrupoid";
                        frmayuda.returndatos = "1,2,4,6";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeSubgrupo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void Delete()
        {
            try
            {
                if (dominioid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Ingrese Código de Dominio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (moduloid.Text.Trim().Length != 4)
                {
                    MessageBox.Show("Ingrese Código de modulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new sys_moduloBL();
                    var BE = new tb_sys_modulo();

                    BE.dominioid = dominioid.Text.Trim();
                    BE.moduloid = moduloid.Text.Trim();

                    if (BL.Delete(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Datos Eliminado correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        data_Tablamodulo();
                        limpiar_documento();
                        form_bloqueado(false);
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = "60";
                BE.moduloid = cboModuloID.SelectedValue.ToString();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Form_help_gridproducto();
                        frmayuda.xfamiliaid = familiaid.Text;
                        frmayuda.xmoduloid = modulo.ToString();
                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA PRODUCTOS >>";
                        frmayuda.sqlquery = "select tb1.productid, tb1.productname,tb1.unmed,tb2.stock, tb2.costoultimo as precventa, tb2.[local] from tb_" + modd + "_productos tb1 ";
                        frmayuda.sqlinner = "left join tb_" + modd + "_local_stock tb2 on tb1.moduloid=tb2.moduloid and tb1.productid=tb2.productid";
                        frmayuda.sqlwhere = "where local ='" + local + "' and tb1.status = '0' ";
                        frmayuda.sqland = "and";
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProductos;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void AyudaFamilia(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = "60";
                BE.moduloid = cboModuloID.SelectedValue.ToString();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();
                        frmayuda.nameform = "color";
                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA FAMILIA - TELA >>";
                        frmayuda.sqlquery = " SELECT es.estructuraid,te.lineaid,te.familiatelaid,(es.estructuraname+'-'+li.lineaname+'-'+te.familiatelaname)familia " +
                                            " FROM tb_" + modd + "_familiatela te ";
                        frmayuda.sqlinner = " LEFT JOIN tb_" + modd + "_linea li ON te.lineaid = li.lineaid " +
                                            " LEFT JOIN tb_" + modd + "_estructura es ON es.estructuraid = li.estructuraid ";
                        frmayuda.sqlwhere = " where";
                        frmayuda.criteriosbusqueda = new string[] { "FAMILIA", "CODIGO" };
                        frmayuda.columbusqueda = "te.familiatelaname,te.familiatelaid";
                        frmayuda.returndatos = "0,1,2,3";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeFamilia;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void ValidaModulo()
        {
            if (dominioid.Text.Trim().Length > 0)
            {
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.moduloid = moduloid.Text.Trim();

                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    moduloid.Text = dt.Rows[0]["moduloid"].ToString().Trim();
                    moduloname.Text = dt.Rows[0]["moduloname"].ToString().Trim();
                }
                else
                {
                    moduloid.Text = "";
                    moduloname.Text = "";
                }
            }
            else
            {
                moduloid.Text = "";
                moduloname.Text = "";
            }
        }
        private void AyudaGrupo(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominioiddes;
                BE.moduloid = moduloiddes.SelectedValue.ToString();
                if (moduloiddes.SelectedValue.ToString() == "0000")
                {
                    MessageBox.Show("Seleccione Almacen", "Information");
                    return;
                }
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA TABLA GRUPOS >>";
                        frmayuda.sqlquery = "SELECT grupoid, gruponame FROM tb_" + modd + "_grupo g ";
                        frmayuda.sqlinner = string.Empty;
                        frmayuda.sqlwhere = "where g.status != '9' ";
                        frmayuda.sqland = "and";
                        frmayuda.criteriosbusqueda = new string[] { "GRUPO", "CODIGO" };
                        frmayuda.columbusqueda = "gruponame,grupoid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeGrupo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void form_cargar_datos(String posicion)
        {
            try
            {
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.dominioid = dominioid.Text.Trim();
                BE.moduloid = item.Text.Trim();
                BE.posicion = posicion.Trim();

                dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    ssModo = "EDIT";
                    limpiar_documento();
                    dominioid.Text = dt.Rows[0]["dominioid"].ToString().Trim();
                    dominioname.Text = dt.Rows[0]["dominioname"].ToString().Trim();
                    item.Text = dt.Rows[0]["moduloid"].ToString().Trim();
                    localname.Text = dt.Rows[0]["moduloname"].ToString().Trim();
                    //moduloshort.Text = dt.Rows[0]["moduloshort"].ToString().Trim();

                    btn_editar.Enabled = true;
                    btn_eliminar.Enabled = true;
                    btn_imprimir.Enabled = true;

                    btn_primero.Enabled = true;
                    btn_anterior.Enabled = true;
                    btn_siguiente.Enabled = true;
                    btn_ultimo.Enabled = true;

                    btn_log.Enabled = true;
                    btn_salir.Enabled = true;
                }
                else
                {
                    limpiar_documento();
                    btn_editar.Enabled = false;
                    btn_eliminar.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AyudaLinea(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA LINEA >>";
                        frmayuda.sqlquery = "SELECT lineaid, lineaname FROM tb_" + modd + "_linea ";
                        frmayuda.sqlinner = string.Empty;
                        frmayuda.sqlwhere = "where";
                        frmayuda.sqland = string.Empty;
                        frmayuda.criteriosbusqueda = new string[] { "LINEA", "CODIGO" };
                        frmayuda.columbusqueda = "lineaname,lineaid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeLinea;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA PRODUCTOS >>";
                        frmayuda.sqlquery = "SELECT tb1.productid, tb1.productname, tb2.stock,tb2.costoultimo FROM tb_me_productos AS tb1 ";
                        frmayuda.sqlinner = "INNER JOIN tb_me_local_stock as tb2 on tb1.productid = tb2.productid ";
                        frmayuda.sqlwhere = "WHERE tb1.moduloid = '" + modulo + "' AND  local = '" + local + "' ";
                        frmayuda.sqland = "AND";
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid";
                        frmayuda.returndatos = "0,1";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProducto;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void Update()
        {
            try
            {
                if (dominioid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Ingrese Código de Dominio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (moduloid.Text.Trim().Length != 4)
                {
                    MessageBox.Show("Ingrese Código de modulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (moduloname.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese nombre de modulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new sys_moduloBL();
                        var BE = new tb_sys_modulo();

                        BE.dominioid = dominioid.Text.Trim();
                        BE.moduloid = moduloid.Text.Trim();
                        BE.moduloname = moduloname.Text.Trim();
                        BE.moduloshort = moduloshort.Text.Trim();

                        if (BL.Update(EmpresaID, BE))
                        {
                            SEGURIDAD_LOG("M");
                            MessageBox.Show("Datos modificado correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_cbo_moduloiddes()
        {
            try
            {
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                BE.dominioid = dominioiddes.Trim();
                BE.status = "0";

                moduloiddes.DataSource = BL.GetAll(EmpresaID, BE).Tables[0];
                moduloiddes.ValueMember = "moduloid";
                moduloiddes.DisplayMember = "moduloname";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_precios_Click(object sender, EventArgs e)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominioid;  //VariablesPublicas.Dominioid;
                BE.moduloid = moduloid;    //VariablesPublicas.Moduloid;
                dt = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();
                        var frmayuda = new Ayudas.Form_help_productoprecio();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = " << *** Ayudas *** >>";
                        frmayuda.sqlquery =
                                "SELECT tb1.productid " +
                                ", tb2.productname " +
                                ", tb1.stock " +
                                ", tb1.costopromed " +
                                ", tb1.valoractual as StockValor " +
                                ", tb1.costoultimo as CostoSoles " +
                                ", tb3.compra as Tcamb" +
                                ", cast(tb1.costoultimo/cast(tb3.compra as decimal(10,4)) as decimal (10,4))as CostoDolar " +
                                " FROM  tb_" + modd + "_local_stock as tb1 ";
                        frmayuda.sqlinner =
                            "INNER JOIN tb_" + modd + "_productos as tb2 ON tb1.productid = tb2.productid " +
                            "INNER JOIN tb_tipocambio as tb3 ON tb3.fecha = CONVERT(date, GETDATE(), 103) ";
                        frmayuda.sqlwhere =
                            "Where " +
                            //"tb1.local = '" + VariablesPublicas.Local + "'" +
                            "tb1.local = '" + local + "'" +
                            "and tb2.status= 0 ";
                        frmayuda.sqland = "and";
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb2.productname,tb1.productid";
                        frmayuda.returndatos = "0,1";
                        frmayuda.Owner = this;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void AyudaGrupo(String lpdescrlike)
        {
            try
            {
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    var frmayuda = new Ayudas.Frm_help_general();

                    frmayuda.tipoo = "sql";
                    frmayuda.titulo = "<< AYUDA TABLA GRUPOS >>";
                    frmayuda.sqlquery = "SELECT grupoid, gruponame FROM tb_me_grupo ";
                    frmayuda.sqlinner = string.Empty;
                    frmayuda.sqlwhere = "where moduloid=" + modulo;
                    frmayuda.sqland = "and ";
                    frmayuda.criteriosbusqueda = new string[] { "GRUPO", "CODIGO" };
                    frmayuda.columbusqueda = "gruponame,grupoid";
                    frmayuda.returndatos = "0,1";

                    frmayuda.Owner = this;
                    frmayuda.PasaProveedor = RecibeGrupo;
                    frmayuda.ShowDialog();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = "60";
                BE.moduloid = cbomodulo.SelectedValue.ToString();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();

                        var frmayuda = new Ayudas.Frm_help_general();

                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA  TABLA PRODUCTOS >>";
                        frmayuda.sqlquery = " SELECT tb1.productid,tb1.productidold, tb1.productname,"+
                                            " SUM(IIF(mdet.almacaccionid = '10',mdet.cantidad * 1,mdet.cantidad *-1)) AS stock, " +
                                            " tb2.costoultimo FROM tb_" + modd + "_productos AS tb1 ";
                        frmayuda.sqlinner = " INNER JOIN tb_" + modd + "_local_stock as tb2 on tb1.productid = tb2.productid "+
                                            " LEFT JOIN tb_" + modd + "_movimientosdet mdet ON tb1.productid = mdet.productid ";
                        frmayuda.sqlwhere = " WHERE ";
                        frmayuda.sqland = string.Empty;
                        frmayuda.sqlgroupby = " GROUP BY tb1.productid,tb1.productidold, tb1.productname,tb2.costoultimo ";

                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO", "CODIGO_ANT" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid,tb1.productidold";
                        frmayuda.returndatos = "0,2";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProducto;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void AyudaProducto(String lpdescrlike)
        {
            try
            {
                var modd = string.Empty;
                var BL = new sys_moduloBL();
                var BE = new tb_sys_modulo();
                var dt = new DataTable();

                BE.dominioid = dominio;
                BE.moduloid = modulo;
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();
                        var frmayuda = new Ayudas.Form_help_gridproducto();
                        frmayuda.tipoo = "sql";
                        frmayuda.titulo = "<< AYUDA PRODUCTO >>";
                        if (modulo == "0500")
                        {
                            // CAMBIAMOS COSTO ULTIMO  X  COSTO PROMEDIO

                            frmayuda.sqlquery = " select tb1.productid, tb1.productname,tb1.unmed, "+
                                                " SUM(IIF(mdet.almacaccionid = '10',mdet.cantidad * 1,mdet.cantidad *-1)) AS stock, " +
                                                " tb2.costopromed as precventa, tb2.[local],tb1.nserie from tb_" + modd + "_productos tb1 ";
                        }
                        else
                        {
                            //frmayuda.sqlquery = " select tb1.productid, tb1.productname,tb1.unmed, "+
                            //                    " SUM(IIF(mdet.almacaccionid = '10',mdet.cantidad * 1,mdet.cantidad *-1)) AS stock, " +
                            //                    " tb2.costoultimo as precventa, tb2.[local] from tb_" + modd + "_productos tb1 ";

                            frmayuda.sqlquery = " select tb1.productid, tb1.productname,tb1.unmed, " +
                                                " tb2.stock, " +
                                                " tb2.costopromed as precventa, tb2.[local] from tb_" + modd + "_productos tb1 ";
                        }

                        if (modulo == "0500")
                        {
                            frmayuda.sqlinner = " LEFT JOIN tb_" + modd + "_local_stock tb2 on tb1.moduloid = tb2.moduloid " +
                                                " AND tb1.productid = tb2.productid "+
                                                " LEFT JOIN tb_" + modd + "_movimientosdet mdet ON tb1.productid = mdet.productid " +
                                                " AND tb2.local = mdet.local ";
                        }
                        else {
                            frmayuda.sqlinner = " LEFT JOIN tb_" + modd + "_local_stock tb2 on tb1.moduloid = tb2.moduloid " +
                                                " AND tb1.productid = tb2.productid ";
                            //+" LEFT JOIN tb_" + modd + "_movimientosdet mdet ON tb1.productid = mdet.productid "+
                            //" AND tb2.local = mdet.local ";
                        }

                        if (modulo == "0500")
                        {
                            frmayuda.sqlwhere = "where tb2.[local] ='" + local + "' ";
                        }
                        else
                        {
                            frmayuda.sqlwhere = "where tb2.[local] ='" + local + "' and tb1.status = '0' ";
                        }

                        frmayuda.sqland = "and";

                        if (modulo == "0500")
                        {
                            frmayuda.sqlgroupby = " GROUP BY tb1.productid " +
                                    ", tb1.productname " +
                                    ", tb1.unmed " +
                                    ", tb2.costopromed " +
                                    ", tb2.local " +
                                    ", tb1.nserie ";

                            //frmayuda.sqlgroupby = "";
                        }
                        else {
                            //frmayuda.sqlgroupby = " GROUP BY tb1.productid " +
                            //        ", tb1.productname " +
                            //        ", tb1.unmed " +
                            //        ", tb2.costopromed " +
                            //        ", tb2.[local] ";

                            frmayuda.sqlgroupby = "";
                        }

                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb1.productname,tb1.productid";
                        frmayuda.returndatos = "0,1,2,6";

                        frmayuda.Owner = this;
                        frmayuda.PasaProveedor = RecibeProductoRollo;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void btn_precios_Click(object sender, EventArgs e)
        {
            try
            {
                String modd = "";
                sys_moduloBL BL = new sys_moduloBL();
                tb_sys_modulo BE = new tb_sys_modulo();
                DataTable dt = new DataTable();

                BE.dominioid = _dominioid;
                BE.moduloid = _moduloid;
                dt = BL.GetAll(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["moduloshort"].ToString().Trim().Length == 2)
                    {
                        modd = dt.Rows[0]["moduloshort"].ToString().Trim();
                        Ayudas.Form_help_productoprecio frmayuda = new Ayudas.Form_help_productoprecio();

                        frmayuda.tipoo = "sql"; //sql,tabla
                        frmayuda.titulo = " << *** Ayudas *** >>";
                        frmayuda.sqlquery =
                                "SELECT tb1.productid "+
                                ", tb2.productname "+
                                ", SUM(IIF(mdet.almacaccionid = '10',mdet.cantidad * 1,mdet.cantidad *-1)) AS stock " +
                                ", tb1.costopromed " +
                                ", tb1.valoractual as StockValor " +
                                ", tb1.costoultimo as CostoSoles " +
                                ", tb3.compra as Tcamb" +
                                ", cast(tb1.costoultimo/cast(tb3.compra as decimal(10,4)) as decimal (10,4))as CostoDolar "+
                                " FROM  tb_" + modd + "_local_stock as tb1 ";
                        frmayuda.sqlinner =
                            "INNER JOIN tb_" + modd + "_productos as tb2 ON tb1.productid = tb2.productid " +
                            "INNER JOIN tb_tipocambio as tb3 ON tb3.fecha = CONVERT(date, GETDATE(), 103) " +
                            "LEFT JOIN tb_" + modd + "_movimientosdet mdet ON tb2.productid = mdet.productid ";
                        frmayuda.sqlwhere =
                            "WHERE " +
                            " tb1.local = '" + _local + "'" +
                            " and tb2.status= 0 ";
                        frmayuda.sqland = " and ";
                        frmayuda.sqlgroupby = " GROUP BY tb1.productid " +
                                ", tb2.productname " +
                                ", tb1.costopromed " +
                                ", tb1.valoractual " +
                                ", tb1.costoultimo " +
                                ", tb3.compra " +
                                ", tb1.costoultimo ";
                        frmayuda.criteriosbusqueda = new string[] { "PRODUCTO", "CODIGO" };
                        frmayuda.columbusqueda = "tb2.productname,tb1.productid";
                        frmayuda.returndatos = "0,1";
                        frmayuda.Owner = this;
                        frmayuda.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }