public Retorno Excluir(LinhaProducao Entity) { try { CommandSQL = new StringBuilder(); CommandSQL.AppendLine("DELETE FROM TB_LINHA_PRODUCAO WHERE CODIGO = @CODIGO"); Command = CriaComandoSQL(CommandSQL.ToString()); Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo); Abrir(); Command.ExecuteNonQuery(); return(new Retorno(true, String.Format(Mensagens.MSG_02, "Excluido "))); } catch (Exception ex) { if (((MySqlException)ex).Number == 1451) { return(new Retorno(false, Mensagens.MSG_16)); } throw ex; } finally { Fechar(); } }
public Retorno Incluir(LinhaProducao Entity) { try { CommandSQL = new StringBuilder(); CommandSQL.AppendLine("INSERT INTO TB_LINHA_PRODUCAO( "); CommandSQL.AppendLine("DATA_PREVISAO_INICIO, "); CommandSQL.AppendLine("DATA_PREVISAO_FIM, "); CommandSQL.AppendLine("QUANTIDADE, "); CommandSQL.AppendLine("CODIGO_FUNCIONARIO, "); CommandSQL.AppendLine("CODIGO_TIPO_STATUS_LINHA_PRODUCAO, "); CommandSQL.AppendLine("CODIGO_PEDIDO_PRODUTO, "); CommandSQL.AppendLine("CODIGO_TERCEIRIZADO) "); CommandSQL.AppendLine("VALUES ("); CommandSQL.AppendLine("@DATA_PREVISAO_INICIO, "); CommandSQL.AppendLine("@DATA_PREVISAO_FIM, "); CommandSQL.AppendLine("@QUANTIDADE, "); CommandSQL.AppendLine("@CODIGO_FUNCIONARIO, "); CommandSQL.AppendLine("@CODIGO_TIPO_STATUS_LINHA_PRODUCAO, "); CommandSQL.AppendLine("@CODIGO_PEDIDO_PRODUTO, "); CommandSQL.AppendLine("@CODIGO_TERCEIRIZADO) "); Command = CriaComandoSQL(CommandSQL.ToString()); Command.Parameters.AddWithValue("@DATA_PREVISAO_INICIO", Entity.DataPrevisaoInicio); Command.Parameters.AddWithValue("@DATA_PREVISAO_FIM", Entity.DataPrevisaoFim); Command.Parameters.AddWithValue("@QUANTIDADE", Entity.Quantidade); Command.Parameters.AddWithValue("@CODIGO_FUNCIONARIO", Entity.Funcionario.Codigo == 0 ? DBNull.Value : (object)Entity.Funcionario.Codigo); Command.Parameters.AddWithValue("@CODIGO_TIPO_STATUS_LINHA_PRODUCAO", (int)EnumTipoStatusLinhaProducao.EM_PRODUCAO); Command.Parameters.AddWithValue("@CODIGO_PEDIDO_PRODUTO", Entity.Produto.CodigoPedidoProduto); Command.Parameters.AddWithValue("@CODIGO_TERCEIRIZADO", Entity.Terceirizado.Codigo == 0 ? DBNull.Value : (object)Entity.Terceirizado.Codigo); Abrir(); Command.ExecuteNonQuery(); return(new Retorno(true, String.Format(Mensagens.MSG_02, "Salvo"))); } catch (Exception ex) { throw ex; } finally { Fechar(); } }
public Retorno Salvar(LinhaProducao Entity) { try { Retorno retorno = PreenchimentoObrigatorio(Entity); if (retorno.IsValido) { if (Entity.Codigo == 0) { retorno = new DataLinhaProducao().Incluir(Entity); } else { retorno = new DataLinhaProducao().Alterar(Entity); } } return(retorno); } catch (Exception ex) { return(Retorno.CriarRetornoExcecao(ex)); } }
public Retorno ConfirmarProducao(LinhaProducao linhaProducao) { try { CommandSQL = new StringBuilder(); CommandSQL.AppendLine("UPDATE TB_LINHA_PRODUCAO SET "); CommandSQL.AppendLine("CODIGO_TIPO_STATUS_LINHA_PRODUCAO = @CODIGO_TIPO_STATUS_LINHA_PRODUCAO, "); CommandSQL.AppendLine("DATA_REAL_FIM = @DATA_REAL_FIM "); CommandSQL.AppendLine("WHERE CODIGO_PEDIDO_PRODUTO = @CODIGO_PEDIDO_PRODUTO"); Command = CriaComandoSQL(CommandSQL.ToString()); Command.Parameters.AddWithValue("@CODIGO_TIPO_STATUS_LINHA_PRODUCAO", (int)EnumTipoStatusLinhaProducao.PRODUZIDO); Command.Parameters.AddWithValue("@DATA_REAL_FIM", DateTime.Now); Command.Parameters.AddWithValue("@CODIGO_PEDIDO_PRODUTO", linhaProducao.Produto.CodigoPedidoProduto); Abrir(); Command.ExecuteNonQuery(); return(new Retorno(true, String.Format(Mensagens.MSG_02, "Produção Confirmada"))); } catch (Exception ex) { throw ex; } finally { Fechar(); } }
public JsonResult Terceirizar(LinhaProducao linhaProducaoTerceirizado) { var retorno = new BusinessLinhaProducao().Terceirizar(linhaProducaoTerceirizado); return(Json(retorno, JsonRequestBehavior.AllowGet)); }
public void updateLinhaProducao(LinhaProducao update_linha) { _context.Entry(update_linha).State = EntityState.Modified; _context.SaveChanges(); }