コード例 #1
0
 protected void BtnIncluirSetor_Click(object sender, EventArgs e)
 {
     if (TxtSetor.Text.Trim() == "")
     {
         Page.ClientScript.RegisterClientScriptBlock(GetType(), "Mensage", "alert('Entre com o nome do setor')", true);
     }
     else
     {
         if (Convert.ToInt32(Request.QueryString["idCliente"]) != 0)
         {
             try
             {
                 Validacoes   ObjValidacoes   = new Validacoes();
                 ClienteSetor ObjClienteSetor = new ClienteSetor();
                 ObjClienteSetor.id = Convert.ToInt32(ObjValidacoes.TextoNull(txtidSetor.Value));
                 ObjClienteSetor.idClienteDepartamento = Convert.ToInt32(DdlDepartamentos.Text);
                 ObjClienteSetor.Nome = TxtSetor.Text;
                 ClienteSetorDAL ObjClienteSetorDAL = new ClienteSetorDAL();
                 ObjClienteSetorDAL.InsertUpdate(ObjClienteSetor);
                 GridSetores.DataBind();
                 TxtSetor.Text    = null;
                 txtidSetor.Value = null;
             }
             catch (Exception ex)
             {
                 Response.Write(ex);
                 Response.End();
             }
         }
         else
         {
             Page.ClientScript.RegisterClientScriptBlock(GetType(), "Mensage", "alert('Salve o cadastro do cliente antes de inserir um setor')", true);
         }
     }
 }
コード例 #2
0
 protected void BtnIncluirSetor_Click(object sender, EventArgs e)
 {
     if (TxtSetor.Text.Trim() == "")
     {
         Page.ClientScript.RegisterClientScriptBlock(GetType(), "Mensage", "alert('Entre com o nome do setor')", true);
     }
     else
     {
         if (Convert.ToInt32(Request.QueryString["idCliente"]) != 0)
         {
             try
             {
                 Validacoes ObjValidacoes = new Validacoes();
                 ClienteSetor ObjClienteSetor = new ClienteSetor();
                 ObjClienteSetor.id = Convert.ToInt32(ObjValidacoes.TextoNull(txtidSetor.Value));
                 ObjClienteSetor.idClienteDepartamento = Convert.ToInt32(DdlDepartamentos.Text);
                 ObjClienteSetor.Nome = TxtSetor.Text;
                 ClienteSetorDAL ObjClienteSetorDAL = new ClienteSetorDAL();
                 ObjClienteSetorDAL.InsertUpdate(ObjClienteSetor);
                 GridSetores.DataBind();
                 TxtSetor.Text = null;
                 txtidSetor.Value = null;
             }
             catch (Exception ex)
             {
                 Response.Write(ex);
                 Response.End();
             }
         }
         else
         {
             Page.ClientScript.RegisterClientScriptBlock(GetType(), "Mensage", "alert('Salve o cadastro do cliente antes de inserir um setor')", true);
         }
     }
 }
コード例 #3
0
 //INSERE UM NOVO REGISTRO OU ATUALIZA UM DETERMINDO REGISTRO JÁ EXISTENTE.
 public void InsertUpdate(ClienteSetor ObjClienteSetor)
 {
     try
     {
         string     NomeProc;
         Database   db            = DatabaseFactory.CreateDatabase();
         Validacoes ObjValidacoes = new Validacoes();
         if (ObjClienteSetor.id != 0)
         {
             NomeProc = "ClienteSetorUpdate";
         }
         else
         {
             NomeProc = "ClienteSetorInsert";
         }
         DbCommand command = db.GetStoredProcCommand(NomeProc);
         //Caso id(chave primaria for diferente de zero(0) então é passado o parametro para fazer o update
         if (ObjClienteSetor.id != 0)
         {
             db.AddInParameter(command, "@ID", DbType.Int32, ObjClienteSetor.id);
         }
         //Dados
         db.AddInParameter(command, "@idClienteDepartamento", DbType.Int32, ObjClienteSetor.idClienteDepartamento);
         db.AddInParameter(command, "@Nome", DbType.String, ObjClienteSetor.Nome);
         //Executa
         db.ExecuteNonQuery(command);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #4
0
    protected void GridSetores_SelectedIndexChanged(object sender, EventArgs e)
    {
        ClienteSetor   ObjClienteSetor   = new ClienteSetor();
        ClienteSetorBO ObjClienteSetorBO = new ClienteSetorBO();

        ObjClienteSetor  = ObjClienteSetorBO.CarregaClienteSetor(Convert.ToInt32(GridSetores.SelectedDataKey.Value)) as ClienteSetor;
        txtidSetor.Value = Convert.ToString(ObjClienteSetor.id);
        TxtSetor.Text    = ObjClienteSetor.Nome;
    }
コード例 #5
0
    //SELECIONA UM DETERMINADO DEPARTAMENTO PARA ALTERAÇÃO DE DADOS.
    public ClienteSetor SelectSetorByID(int id)
    {
        Database  db      = DatabaseFactory.CreateDatabase();
        DbCommand command = db.GetSqlStringCommand("Select * From ClienteSetor Where id = " + id);

        db.AddInParameter(command, "@id", DbType.Int32, id);

        using (IDataReader dr = db.ExecuteReader(command))
        {
            ClienteSetor ObjClienteSetor = new ClienteSetor();
            if (dr.Read())
            {
                //DADOS
                ObjClienteSetor.id = Convert.ToInt32(dr["id"]);
                ObjClienteSetor.idClienteDepartamento = Convert.ToInt32(dr["idClienteDepartamento"]);
                ObjClienteSetor.Nome = Convert.ToString(dr["Nome"]);
            }
            return(ObjClienteSetor);
        }
    }
コード例 #6
0
 protected void GridSetores_SelectedIndexChanged(object sender, EventArgs e)
 {
     ClienteSetor ObjClienteSetor = new ClienteSetor();
     ClienteSetorBO ObjClienteSetorBO = new ClienteSetorBO();
     ObjClienteSetor = ObjClienteSetorBO.CarregaClienteSetor(Convert.ToInt32(GridSetores.SelectedDataKey.Value)) as ClienteSetor;
     txtidSetor.Value = Convert.ToString(ObjClienteSetor.id);
     TxtSetor.Text = ObjClienteSetor.Nome;
 }