public static string Excluir(TRegistro_CadLocalArm val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_CadLocalArm cd = new TCD_CadLocalArm(); try { if (banco == null) { st_transacao = cd.CriarBanco_Dados(true); } else { cd.Banco_Dados = banco; } //Verificar se existe amarracao para o local if (new TCD_CadLocalArm_X_Empresa(cd.Banco_Dados).BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.cd_local", vOperador = "=", vVL_Busca = "'" + val.Cd_local.Trim() + "'" } }, "1") != null) { val.St_registro = "C"; cd.Gravar(val); } else { cd.Excluir(val); } if (st_transacao) { cd.Banco_Dados.Commit_Tran(); } return(val.Cd_local); } catch (Exception ex) { if (st_transacao) { cd.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro excluir local armazenagem: " + ex.Message.Trim()); } finally { if (st_transacao) { cd.deletarBanco_Dados(); } } }
public static string Gravar(TRegistro_CadLocalArm val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_CadLocalArm cd = new TCD_CadLocalArm(); try { if (banco == null) { st_transacao = cd.CriarBanco_Dados(true); } else { cd.Banco_Dados = banco; } val.Cd_local = CamadaDados.TDataQuery.getPubVariavel(cd.Gravar(val), "@P_CD_LOCAL"); if (st_transacao) { cd.Banco_Dados.Commit_Tran(); } return(val.Cd_local); } catch (Exception ex) { if (st_transacao) { cd.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro gravar local armazenagem: " + ex.Message.Trim()); } finally { if (st_transacao) { cd.deletarBanco_Dados(); } } }
private void BuscarProduto() { TpBusca[] filtro = new TpBusca[1]; filtro[0].vNM_Campo = "isnull(e.ST_Servico, 'N')"; filtro[0].vOperador = pSt_servico ? "=" : "<>"; filtro[0].vVL_Busca = "'S'"; if (St_consumoInterno) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "isnull(e.ST_consumointerno, 'N')"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = "'S'"; } TRegistro_CadProduto rProd = null; if (string.IsNullOrEmpty(CD_Produto.Text)) { rProd = UtilPesquisa.BuscarProduto(string.Empty, CD_Empresa, Nm_empresa, CD_TabelaPreco, new Componentes.EditDefault[] { CD_Produto, DS_Produto }, filtro); } else if (CD_Produto.Text.SoNumero().Trim().Length != CD_Produto.Text.Trim().Length) { rProd = UtilPesquisa.BuscarProduto(CD_Produto.Text, CD_Empresa, Nm_empresa, CD_TabelaPreco, new Componentes.EditDefault[] { CD_Produto, DS_Produto }, filtro); } else { Array.Resize(ref filtro, filtro.Length + 2); filtro[filtro.Length - 2].vNM_Campo = "isnull(a.st_registro, 'A')"; filtro[filtro.Length - 2].vOperador = "<>"; filtro[filtro.Length - 2].vVL_Busca = "'C'"; filtro[filtro.Length - 1].vNM_Campo = string.Empty; filtro[filtro.Length - 1].vOperador = string.Empty; filtro[filtro.Length - 1].vVL_Busca = "(a.cd_produto like '%" + CD_Produto.Text.Trim() + "') or " + "(a.Codigo_Alternativo = '" + (CD_Produto.TextOld != null ? CD_Produto.TextOld.ToString() : CD_Produto.Text.Trim()) + "') or " + "(exists(select 1 from tb_est_codbarra x " + " where x.cd_produto = a.cd_produto " + " and x.cd_codbarra = '" + CD_Produto.Text.Trim() + "'))"; TList_CadProduto lProd = new TCD_CadProduto().Select(filtro, 0, string.Empty, string.Empty, string.Empty); if (lProd.Count > 0) { rProd = lProd[0]; } } if (rProd != null) { CD_Produto.Text = rProd.CD_Produto; DS_Produto.Text = rProd.DS_Produto; sigla_unidade.Text = rProd.Sigla_unidade; DS_Observacao.Text = rProd.DS_Tecnica; st_kit.Checked = rProd.St_composto; if ((!st_servico.Checked)) { //Buscar local armazenagem object obj = new TCD_CadLocalArm().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = string.Empty, vOperador = "exists", vVL_Busca = "(select 1 from tb_est_empresa_x_localarm x " + "where x.cd_local = a.cd_local " + "and x.cd_empresa = '" + CD_Empresa.Trim() + "')" }, new TpBusca() { vNM_Campo = string.Empty, vOperador = "exists", vVL_Busca = "(select 1 from tb_est_localarm_x_produto x " + "where x.cd_local = a.cd_local " + "and x.cd_produto = '" + CD_Produto.Text.Trim() + "')" } }, "a.cd_local"); if (obj != null) { CD_Local.Text = obj.ToString(); CD_Local_Leave(this, new EventArgs()); Quantidade.Focus(); } else { if (string.IsNullOrEmpty(CD_Local.Text)) { CD_Local.Focus(); } else { Quantidade.Focus(); } } } if (st_kit.Checked) { Height = 900; Quantidade.Value = 1; try { (BS_Pecas.Current as TRegistro_LanServicosPecas).lFichaTecOS = TCN_LanServicoPecas.MontarFichaTecOS(CD_Produto.Text, CD_Empresa, Quantidade.Value, null); BS_Pecas.ResetCurrentItem(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { Height = 456; (BS_Pecas.Current as TRegistro_LanServicosPecas).lFichaTecOS.Clear(); BS_Pecas.ResetCurrentItem(); } } ConsultaPreco(); }
private void afterNovo() { pDados.Enabled = true; cd_produto.Enabled = true; cd_empresa.Enabled = true; bb_empresa.Enabled = true; cd_local.Enabled = true; bb_local.Enabled = true; cd_tabelapreco.Enabled = true; bb_tabpreco.Enabled = true; vl_precovenda.Enabled = true; codBarra.Enabled = true; qtd_entrada.Enabled = true; vl_entrada.Enabled = true; BB_Novo.Visible = false; BB_Gravar.Visible = true; BB_Cancelar.Visible = true; LimparCampos(); //Buscar empresa do usuario object obj_emp = new CamadaDados.Diversos.TCD_CadUsuario_Empresa().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.login", vOperador = "=", vVL_Busca = "'" + Parametros.pubLogin.Trim() + "'" } }, "a.cd_empresa"); Cd_empdefault = obj_emp != null?obj_emp.ToString() : string.Empty; //Buscar Config Cupom lCfg = CamadaNegocio.Faturamento.Cadastros.TCN_CFGCupomFiscal.Buscar((Cd_empdefault), null); //Preencher CD.Empresa if (lCfg.Count > 0) { cd_empresa.Text = lCfg[0].Cd_empresa.Trim(); } else { cd_empresa.Text = Cd_empdefault; } cd_empresa_Leave(this, new EventArgs()); //Tabela Preco cd_tabelapreco.Text = "01"; cd_tabelapreco_Leave(this, new EventArgs()); //Buscar local armazenagem object obj = new TCD_CadLocalArm().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = string.Empty, vOperador = "exists", vVL_Busca = "(select 1 from tb_est_empresa_x_localarm x " + "where x.cd_local = a.cd_local " + "and x.cd_empresa = '" + cd_empresa.Text.Trim() + "')" } }, "a.cd_local"); if (obj != null) { cd_local.Text = obj.ToString(); cd_local_Leave(this, new EventArgs()); } cd_produto.Focus(); }