public DataSet GetAll_Version(string empresaid, tb_pp_hojacostocab BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpHojacostocab_SEARCH_Version", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@articid", SqlDbType.Char, 4).Value = BE.articid;
                 cmd.Parameters.Add("@version", SqlDbType.Char, 3).Value = BE.version;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Delete(string empresaid, tb_pp_hojacostocab BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpHojacostocab_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@articid", SqlDbType.Char, 4).Value = BE.articid;
                 cmd.Parameters.Add("@version", SqlDbType.Char, 3).Value = BE.version;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Update(string empresaid, tb_pp_hojacostocab BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_pp_hojacostocab BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetAll_Version(string empresaid, tb_pp_hojacostocab BE)
 {
     return tablaDA.GetAll_Version(empresaid, BE);
 }
        private void Delete()
        {
            try
            {
                var BL = new tb_pp_hojacostocabBL();
                var BE = new tb_pp_hojacostocab();

                BE.articid = articid.Text.Trim();
                BE.version = version.Text.Trim();

                if (BL.Delete(EmpresaID, BE))
                {
                    SEGURIDAD_LOG("E");
                    MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NIVEL_FORMS();
                    limpiar_documento();
                    form_bloqueado(false);
                    btn_nuevo.Enabled = true;
                    btn_busqueda.PerformClick();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_busqueda_Click(object sender, EventArgs e)
        {
            var BE = new tb_pp_hojacostocab();
            var BL = new tb_pp_hojacostocabBL();

            BE.articidold = txt_criterio.Text.ToString().Trim();
            Tablaprecioslist = BL.GetAll(EmpresaID, BE).Tables[0];
            if (Tablaprecioslist.Rows.Count > 0)
            {
                Mdi_dgv_listahojacosto.DataSource = Tablaprecioslist;
            }
            else
            {
                Mdi_dgv_listahojacosto.DataSource = Tablaprecioslist;
            }
        }
        private void RecibeArticulo(String xarticid, String xarticidold, String xarticname, String resultado4, String resultado5)
        {
            if (xarticid.Trim().Length > 0)
            {
                articid.Text = xarticid.Trim();
                articidold.Text = xarticidold.Trim();
                articname.Text = xarticname.Trim();
                var BL = new tb_pp_hojacostocabBL();
                var BE = new tb_pp_hojacostocab();
                var dt = new DataTable();

                BE.articid = articid.Text.ToString();
                BE.version = string.Empty;
                dt = BL.GetAll_Version(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    version.Text = dt.Rows[0]["codigo"].ToString();
                }
                else
                {
                    version.Text = string.Empty;
                }
            }
        }
 public bool Update(string empresaid, tb_pp_hojacostocab BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpHojacostocab_UPDATE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@articid", SqlDbType.Char, 4).Value = BE.articid;
                 cmd.Parameters.Add("@version", SqlDbType.Char, 3).Value = BE.version;
                 cmd.Parameters.Add("@fecha", SqlDbType.DateTime).Value = BE.fecha;
                 cmd.Parameters.Add("@cantidad", SqlDbType.Decimal).Value = BE.cantidad;
                 cmd.Parameters.Add("@costoprimo", SqlDbType.Decimal).Value = BE.costoprimo;
                 cmd.Parameters.Add("@percgadm", SqlDbType.Decimal).Value = BE.percgadm;
                 cmd.Parameters.Add("@percgvta", SqlDbType.Decimal).Value = BE.percgvta;
                 cmd.Parameters.Add("@percgfin", SqlDbType.Decimal).Value = BE.percgfin;
                 cmd.Parameters.Add("@gastoadm", SqlDbType.Decimal).Value = BE.gastoadm;
                 cmd.Parameters.Add("@gastovta", SqlDbType.Decimal).Value = BE.gastovta;
                 cmd.Parameters.Add("@gastofin", SqlDbType.Decimal).Value = BE.gastofin;
                 cmd.Parameters.Add("@gastopera", SqlDbType.Decimal).Value = BE.gastopera;
                 cmd.Parameters.Add("@costototal", SqlDbType.Decimal).Value = BE.costototal;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }