public DataSet GetAll(string empresaid, tb_pp_rubrocosto BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpRubrocosto_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 2).Value = BE.rubroid;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@rubroname", SqlDbType.VarChar, 30).Value = BE.rubroname;
                 cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                 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 Delete(string empresaid, tb_pp_rubrocosto BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPpRubrocosto_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 2).Value = BE.rubroid;
                 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);
             }
         }
     }
 }
 public bool Update(string empresaid, tb_pp_rubrocosto BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_pp_rubrocosto BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetAll(string empresaid, tb_pp_rubrocosto BE)
 {
     return tablaDA.GetAll(empresaid, BE);
 }
 private void cmb_rubro_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmb_rubro.SelectedIndex >= 0)
     {
         var BL = new tb_pp_rubrocostoBL();
         var BE = new tb_pp_rubrocosto();
         var dt = new DataTable();
         BE.rubroid = cmb_rubro.SelectedValue.ToString();
         dt = BL.GetAll(EmpresaID, BE).Tables[0];
         if (dt.Rows.Count > 0)
         {
             cboModuloID.SelectedValue = dt.Rows[0]["moduloid"].ToString();
         }
         familiaid.Focus();
     }
 }
        private void CargarFilasdeHojadeRubro()
        {
            if (TablaCostoRubro.Rows.Count > 0)
            {
                TablaCostoRubro.Rows.Clear();
                dgb_hojacostorubro.DataSource = TablaCostoRubro;
            }

            var BL = new tb_pp_rubrocostoBL();
            var BE = new tb_pp_rubrocosto();
            var dt = new DataTable();
            dt = BL.GetAll(EmpresaID, BE).Tables[0];

            var xxrubroname = string.Empty;
            foreach (DataRow fila in dt.Rows)
            {
                var xxrubroid = fila["rubroid"].ToString();
                var xxmoduloid = fila["moduloid"].ToString();
                Decimal AcumImporte = 0;
                var result = TablaprecioslistDet.Select("rubroid = '" + xxrubroid.ToString() + "' AND moduloid = '" + xxmoduloid.ToString() + "' ");

                foreach (DataRow list in result)
                {
                    AcumImporte = AcumImporte + Convert.ToDecimal(list["importe"]);
                    xxrubroname = list["rubroname"].ToString();
                }

                if (AcumImporte > 0)
                {
                    row = TablaCostoRubro.NewRow();
                    row["articid"] = articid.Text.ToString();
                    row["version"] = version.Text.ToString();
                    row["rubroid"] = fila["rubroid"].ToString();
                    row["rubroname"] = xxrubroname.ToString();
                    row["moduloid"] = cboModuloID.SelectedValue.ToString();
                    row["importe"] = AcumImporte.ToString();
                    row["usuar"] = VariablesPublicas.Usuar.ToString();
                    TablaCostoRubro.Rows.Add(row);
                }
            }

            dgb_hojacostorubro.DataSource = TablaCostoRubro;
            _CalculoGastosCostos();
        }
 private void get_cbo_rubro()
 {
     var BL = new tb_pp_rubrocostoBL();
     var BE = new tb_pp_rubrocosto();
     var dt = new DataTable();
     try
     {
         dt = BL.GetAll(EmpresaID, BE).Tables[0];
         cmb_rubro.DataSource = dt;
         cmb_rubro.ValueMember = "rubroid";
         cmb_rubro.DisplayMember = "rubroname";
         cmb_rubro.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void Update()
        {
            try
            {
                if (cboModuloID.SelectedIndex == -1)
                {
                    MessageBox.Show("Seleccion un Modulo...!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_pp_rubrocostoBL();
                    var BE = new tb_pp_rubrocosto();

                    BE.moduloid = cboModuloID.SelectedValue.ToString();
                    BE.rubroid = rubroid.Text;
                    BE.rubroname = rubroname.Text.ToUpper();
                    BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Update(EmpresaID, BE))
                    {
                        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 Delete()
        {
            try
            {
                if (cboModuloID.SelectedIndex == -1)
                {
                    MessageBox.Show("Seleccion un Modulo...!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_pp_rubrocostoBL();
                    var BE = new tb_pp_rubrocosto();

                    BE.moduloid = cboModuloID.SelectedValue.ToString();
                    BE.rubroid = rubroid.Text;

                    if (BL.Delete(EmpresaID, BE))
                    {
                        MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        limpiar_documento();
                        form_bloqueado(false);
                        Data_TablaConstantes();
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Data_TablaConstantes()
        {
            try
            {
                if (cboModuloID.SelectedIndex != -1)
                {
                    if (TablaRubroCosto.Rows.Count > 0)
                    {
                        TablaRubroCosto.Rows.Clear();
                    }
                    var BL = new tb_pp_rubrocostoBL();
                    var BE = new tb_pp_rubrocosto();

                    BE.moduloid = cboModuloID.SelectedValue.ToString();

                    TablaRubroCosto = BL.GetAll(EmpresaID, BE).Tables[0];
                    if (TablaRubroCosto.Rows.Count > 0)
                    {
                        btn_imprimir.Enabled = true;
                        MDI_dgb_rubrocosto.DataSource = TablaRubroCosto;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool Insert(string empresaid, tb_pp_rubrocosto BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbPpRubrocosto_INSERT", cnx))
                {

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@rubroid", SqlDbType.Char, 2).Value = BE.rubroid;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@rubroname", SqlDbType.VarChar, 30).Value = BE.rubroname;
                    cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    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);
                    }
                }
            }
        }