public bool Delete(string empresaid, tb_pp_hojacosto 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 DataSet GetAll(string empresaid, tb_pp_hojacosto BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpHojacostocab_SEARCH", 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;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public bool Update(string empresaid, tb_pp_hojacosto BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbPpHojacosto_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;

                        cmd.Parameters.Add("@XML", SqlDbType.Xml).Value = BE.GetItemXML();
                        cmd.Parameters.Add("@XML2", SqlDbType.Xml).Value = BE.GetItemXML2();
                    }
                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        private void Update()
        {
            try
            {
                var BL = new tb_pp_hojacostoBL();
                var BE = new tb_pp_hojacosto();

                BE.articid = articid.Text.ToString();
                BE.version = version.Text.ToString();
                BE.fecha = Convert.ToDateTime(DateTime.Today.ToShortDateString());
                BE.cantidad = Convert.ToInt32(cantidad.Text.ToString());
                BE.costoprimo = Convert.ToDecimal(costoprimo.Text.ToString());
                BE.percgadm = Convert.ToDecimal(percgadm.Text.ToString());
                BE.percgvta = Convert.ToDecimal(percgvta.Text.ToString());
                BE.percgfin = Convert.ToDecimal(percgfin.Text.ToString());
                BE.gastoadm = Convert.ToDecimal(gastoadm.Text.ToString());
                BE.gastovta = Convert.ToDecimal(gastovta.Text.ToString());
                BE.gastofin = Convert.ToDecimal(gastofin.Text.ToString());
                BE.gastopera = Convert.ToDecimal(gastopera.Text.ToString());
                BE.costototal = Convert.ToDecimal(costototal.Text.ToString());
                BE.perianio = Convert.ToString(DateTime.Today.Year);
                BE.usuar = VariablesPublicas.Usuar.Trim();

                var Detalle = new tb_pp_hojacosto.Item();
                var ListaItems = new List<tb_pp_hojacosto.Item>();

                var item = 0;
                foreach (DataRow fila in TablaprecioslistDet.Rows)
                {
                    Detalle = new tb_pp_hojacosto.Item();
                    item++;

                    Detalle.articid = fila["articid"].ToString();
                    Detalle.version = fila["version"].ToString();
                    Detalle.rubroid = fila["rubroid"].ToString();
                    Detalle.moduloid = fila["moduloid"].ToString();
                    Detalle.lineaid = fila["lineaid"].ToString().Trim();
                    Detalle.familiaid = fila["familiaid"].ToString();
                    Detalle.valor = Convert.ToDecimal(fila["valor"].ToString());
                    Detalle.consumo = Convert.ToDecimal(fila["consumo"].ToString().Trim());
                    Detalle.unmed = fila["unmed"].ToString().Trim();
                    Detalle.importe = Convert.ToDecimal(fila["importe"].ToString().Trim());
                    Detalle.status = fila["status"].ToString().Trim();
                    Detalle.usuar = fila["usuar"].ToString().Trim();

                    ListaItems.Add(Detalle);
                }

                if (ListaItems.Count == 0)
                {
                    MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                BE.ListaItems = ListaItems;

                var Atributos = new tb_pp_hojacosto.Item();
                var ListaItems2 = new List<tb_pp_hojacosto.Item>();
                var item2 = 0;
                foreach (DataRow fila in TablaCostoRubro.Rows)
                {
                    Atributos = new tb_pp_hojacosto.Item();
                    item2++;

                    Atributos.articid = fila["articid"].ToString();
                    Atributos.version = fila["version"].ToString();
                    Atributos.rubroid = fila["rubroid"].ToString();
                    Atributos.moduloid = fila["moduloid"].ToString();
                    Atributos.importe = Convert.ToDecimal(fila["importe"].ToString().Trim());
                    Atributos.usuar = fila["usuar"].ToString().Trim();

                    ListaItems2.Add(Atributos);
                }

                if (ListaItems2.Count == 0)
                {
                    MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                BE.ListaItems2 = ListaItems2;

                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);
            }
        }
 public bool Update(string empresaid, tb_pp_hojacosto BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_pp_hojacosto BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetAll(string empresaid, tb_pp_hojacosto BE)
 {
     return tablaDA.GetAll(empresaid, BE);
 }