Example #1
0
        /// <summary>
        /// Evento ao selecionar botão gravar. Alterar dados do material na obra (tblObraGrupoMaterial)
        /// e dados de estoque de material (tblObraGrupoMaterialEstoque)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            tblObraGrupoMaterial table = new tblObraGrupoMaterial();
            bool ok = false;

            try
            {
                table.cmpCoObraGrupoMaterial = ViewState["cmpCoObraGrupoMaterial"].ToString();
                table.cmpDcItem = txtItemMaterial2.Text;
                table.cmpDcMaterialObraGrupo = txtDescricao2.Text;
                table.cmpNuQtdContrato       = txtQtContrato.Text.Replace(",", ".");
                table.cmpVlPrecoUnitario     = txtPrecoMaterial2.Text.Replace(",", ".");
                table.cmpNoUsuario           = ((HzLogin)Session["login"]).cmpNoUsuario;

                if (!(ok = table.AlterarObraGrupoMaterial(Global.GetConnection())))
                {
                    throw new Exception("Erro ao alterar dados do material da obra!");
                }
                CarregaDadosMaterialObra();
            }
            catch (Exception ex)
            {
                Global.ShowError(Global.Title, ex);
            }
        }
Example #2
0
        /// <summary>
        /// Evento ao desvincular material da Obra (tblObraGrupoMaterial).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDesvincular_Click(object sender, EventArgs e)
        {
            try
            {
                tblObraGrupoMaterial table = new tblObraGrupoMaterial();
                string mensagem            = "";

                foreach (ListItem item in lstMaterial1.Items)
                {
                    if (item.Selected)
                    {
                        table.cmpCoObraGrupoMaterial = item.Value.ToString();
                        table.cmpCoObraGrupo         = ViewState["cmpCoObraGrupo"].ToString();
                        table.cmpNoUsuario           = ((HzLogin)Session["login"]).cmpNoUsuario;

                        table.ExcluirObraGrupoMaterial(Global.GetConnection(), ref mensagem);
                        if (mensagem != "")
                        {
                            CaixaMensagem.Mostar(Mensagem.Tipo.Erro, mensagem);
                        }
                        else
                        {
                            CaixaMensagem.Mostar(Mensagem.Tipo.Erro, "Material excluído da obra!");
                            LimparCampos();
                            CarregaMaterialNotObra();
                            if (lstMaterial1.Items.Count == 1)
                            {
                                lstMaterial1.Items.Clear();
                                break;
                            }
                            else
                            {
                                CarregaMaterialObra();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Global.ShowError(Global.Title, ex);
            }
        }
Example #3
0
        /// <summary>
        /// Evento ao vincular material de referência (tblMaterial) com a Obra (tblObraGrupoMaterial).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnVincular_Click(object sender, EventArgs e)
        {
            tblObraGrupoMaterial table = new tblObraGrupoMaterial();
            bool ok = false;

            try
            {
                foreach (ListItem item in lstMaterial0.Items)
                {
                    if (item.Selected)
                    {
                        ViewState["cmpCoMaterial"] = item.Value;
                        CarregaDadosMaterialNotObra();

                        table.cmpCoObraGrupoMaterial = "0";
                        table.cmpCoObraGrupo         = ViewState["cmpCoObraGrupo"].ToString();
                        table.cmpCoMaterial          = ViewState["cmpCoMaterial"].ToString();
                        table.cmpDcItem = txtItemMaterial1.Text;
                        table.cmpDcMaterialObraGrupo = txtDescricao1.Text.ToUpper();
                        table.cmpNuQtdContrato       = "0";
                        table.cmpVlPrecoUnitario     = txtPrecoMaterial1.Text.Replace(",", ".");
                        table.cmpNoUsuario           = ((HzLogin)Session["login"]).cmpNoUsuario;

                        if (!(ok = table.GravarObraGrupoMaterial(Global.GetConnection())))
                        {
                            throw new Exception("Erro ao cadastrar o(s) material(ais) da obra!");
                        }
                    }
                }

                CarregaMaterialNotObra();
                CarregaMaterialObra();
            }
            catch (Exception ex)
            {
                Global.ShowError(Global.Title, ex);
            }
        }